Click here to Skip to main content
Rate this: bad
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
Edited 4-Jan-13 23:43pm
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 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 8,438
1 OriginalGriff 6,491
2 Peter Leow 3,567
3 Zoltán Zörgő 3,326
4 Richard MacCutchan 2,397

Advertise | Privacy | Mobile
Web01 | 2.8.150123.1 | Last Updated 6 Jan 2013
Copyright © CodeProject, 1999-2015
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