Drop Down in Datagrid Edit Template

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • agarwalsunitadhn
    New Member
    • Jan 2008
    • 82

    Drop Down in Datagrid Edit Template

    hello
    I am using drop down in edit template instead of textbox. it runs properly bt problem is that when i click on the edit button then the selected value doesnt shown there, instead of 0th index value is shown in drop down.
    I want that the value which was shown on datagrid before edit is also shown after clicking on the edit button.

    Thanks in advance for your valuable suggestions
  • formanite007
    New Member
    • Feb 2008
    • 3

    #2
    In your grid views' _RowEditing function load your drop downs as you would noramly and then use FindByText method giving text box values as parameters search that list item and set its Selected property to TRUE.

    e.g.

    dropDownReviewT ype.Items.FindB yText(((TextBox )gridReview.Row s[e.NewEditIndex].FindControl("R eviewTypeTextBo x")).Text).Sele cted = true;

    Comment

    • agarwalsunitadhn
      New Member
      • Jan 2008
      • 82

      #3
      Originally posted by formanite007
      In your grid views' _RowEditing function load your drop downs as you would noramly and then use FindByText method giving text box values as parameters search that list item and set its Selected property to TRUE.

      e.g.

      dropDownReviewT ype.Items.FindB yText(((TextBox )gridReview.Row s[e.NewEditIndex].FindControl("R eviewTypeTextBo x")).Text).Sele cted = true;

      Hello
      Thanks. But in this code i am not understanding that what's the dropdown field name and when i type this one i got an error. and even i dnt find the FindByText method. Is it user defined?
      Please give me your suggestion in detail.
      Thanks once again

      Comment

      • formanite007
        New Member
        • Feb 2008
        • 3

        #4
        In Follwoing:
        dropDownReviewT ype.Items.FindB yText(((TextBox )grid Review.Rows[e.NewEditIndex].FindControl("R eviewTypeTextBo x")).Text).Sele cted = true;

        DropDown name is dropDownReviewT ype and the function is in the Items collection.
        Here actually i am trying to find that List item whose text is same as the ReviewTypeTextB ox's Text property and setting its value to selcted.

        Hope it clarifies...
        paste the error if you still encounter one.

        Comment

        • agarwalsunitadhn
          New Member
          • Jan 2008
          • 82

          #5
          Originally posted by formanite007
          In Follwoing:
          dropDownReviewT ype.Items.FindB yText(((TextBox )grid Review.Rows[e.NewEditIndex].FindControl("R eviewTypeTextBo x")).Text).Sele cted = true;

          DropDown name is dropDownReviewT ype and the function is in the Items collection.
          Here actually i am trying to find that List item whose text is same as the ReviewTypeTextB ox's Text property and setting its value to selcted.

          Hope it clarifies...
          paste the error if you still encounter one.

          And what's FindByText here.if i type this one i got an error

          Comment

          • formanite007
            New Member
            • Feb 2008
            • 3

            #6
            Originally posted by agarwalsunitadh n
            And what's FindByText here.if i type this one i got an error
            Have a look at MSDN ListControl.Ite ms, its a function of it.

            Comment

            Working...