Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP:NET
<asp:Label ID="lblAge" runat="server" Text='<%#Eval("FbUserAge")%>'></asp:Label>
 
<br />
<asp:Label ID="lblCity" runat="server" Text='<%#Eval("ManualCity")%>'></asp:Label>
  protected void grdUser_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowState == DataControlRowState.Edit || e.Row.RowState == (DataControlRowState.Edit | DataControlRowState.Alternate))
        {
            try
            {
                
 
                DropDownList drp = (DropDownList)(e.Row.FindControl("drpAge"));
                
                
                    DataSet objdst = new DataSet();
                    objdst = objFb.FillAge();
                    drp.DataSource = objdst.Tables[0];
                    drp.DataValueField = "FbUserAge";
                    drp.DataTextField = "FbUserAge";
                    drp.DataBind();
                    if (drp.Items.Count > 0)
                    {
                        Label lb = (Label)(e.Row.FindControl("lblAge"));
                        drp.SelectedIndex = drp.Items.IndexOf(drp.Items.FindByValue(lb.Text));
                    }
            }
 
            catch (Exception ex)
            {
                throw ex;
            }
        }
       
     
       
      }
Posted 4-Jan-13 21:43pm
Edited 4-Jan-13 23:43pm
v2
Comments
Sandeep Mewara at 5-Jan-13 3:09am
   
This is not a well framed question! We cannot work out what you are trying to do/ask from the post. Please elaborate and be specific.
Use the "Improve question" link to edit your question and provide better information.
sachinsharmaa102 at 5-Jan-13 4:47am
   
I want to bind the label's text to dropdownlist ...actually the label is in the itemtemplate and the dropdownlist is in the edittemplate ...as you can see above that i have value coming as text on the label and i want this text to be displayed in the dropdownlist.
Krunal Rohit at 6-Jan-13 9:26am
   
have you tries with Session..??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 345
1 OriginalGriff 210
2 DamithSL 210
3 Kornfeld Eliyahu Peter 210
4 Peter Leow 95
0 OriginalGriff 7,215
1 DamithSL 5,199
2 Maciej Los 4,866
3 Sergey Alexandrovich Kryukov 4,757
4 Kornfeld Eliyahu Peter 4,514


Advertise | Privacy | Mobile
Web02 | 2.8.141223.1 | Last Updated 6 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100