how to bind label inside panel and panel inside gdview

Posted by Shanky11 under ASP.NET on 9/27/2012 | Points: 10 | Views : 1662 | Status : [Member] | Replies : 1
<asp:TemplateField>
<ItemTemplate>
<asp:Panel ID="pnlTest" runat="server">
<asp:Label ID="lblTest" runat="server" Text="Test"></asp:Label>
</asp:Panel>
<asp:Button ID="btnTest" runat="server" Text="check" CommandName="check" CommandArgument="chk"/>
</ItemTemplate>
</asp:TemplateField>
--------------page code not working--------
button_click
{
Panel p= new Panel();
p= (Panel) gdview1.FindControl("pnlTest");
Label lblTestLocal = new Label();
lblTestLocal = (Label)pnlTestLocal.FindControl("lblTest");
lblTestLocal.Text = "Working";
}
p is showing null why?????????????????????




Responses

Posted by: Jayakumars on: 9/27/2012 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi

shaky try this working Good for me.

if (!IsPostBack)
{
sqlcon.Open();
SqlDataAdapter sqladp = new SqlDataAdapter("select * from [employee]", sqlcon);
sqladp.Fill(dt);
gdview1.DataSource = dt;
gdview1.DataBind();
}

foreach (GridViewRow row in gdview1.Rows)
{
Label lblid = (Label)row.FindControl("lblpropertyname");
Response.Write(lblid.Text);
}

Please mark as answer if it helpful to you.

Mark as Answer if its helpful to you

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response