Click here to Skip to main content
12,251,445 members (60,724 online)
Rate this:
 
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")%>'>
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 20:43pm
Edited 4-Jan-13 22:43pm
v2
Comments
Sandeep Mewara 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 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 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 6 Jan 2013
Copyright © CodeProject, 1999-2016
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