Click here to Skip to main content
12,747,448 members (37,734 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")%>'></asp:Label>

  protected void grdUser_RowDataBound(object sender, GridViewRowEventArgs e)
        if (e.Row.RowState == DataControlRowState.Edit || e.Row.RowState == (DataControlRowState.Edit | DataControlRowState.Alternate))

                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";
                    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
Updated 4-Jan-13 23:43pm
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 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.170215.1 | Last Updated 6 Jan 2013
Copyright © CodeProject, 1999-2017
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