Last post Jul 18, 2010 07:12 PM by nkour
Jul 18, 2010 01:56 PM|nkour|LINK
Hello I have ListView and in the ItemTemplate I have:
<asp:Panel ID="Panel1" runat="server">
<asp:LinkButton ID="LinkButton" Text="Save" runat="server"
<asp:TextBox ID="TextBox1" "runat="server" />
in code behind I'm doing:
the ItemCommand fires but TextBox1 is ALWAYS null! I've tried to findcontrol on Panel2 and it works!
Jul 18, 2010 03:47 PM|Hisham.NET|LINK
Hi nkour ...
Try this ...
TextBox TextBox1=( (e.Item.FindControl("Panel2") as Panel).FindControl("TextBox1") )as TextBox;
Jul 18, 2010 03:50 PM|Steelymar|LINK
TextBox TextBox1 = (e.Item.FindControl("Panel2").FindControl("TextBox1")
Jul 18, 2010 05:44 PM|sansan|LINK
Jul 18, 2010 06:54 PM|nkour|LINK
guys, you all suggest the same which solves the problem didn't know that I have to do FindControl on the Panel!! I wish it was recursive
Now I've noticied that it doesn't work as I was expecting the fact that I do:
In the ItemCommand event handler (only works good in the ItemDataBound) too. do I have to somehow use hiddenfield?
I want to update the object that is represented in this listviewitem with some now info
Jul 18, 2010 07:01 PM|PeteNet|LINK
FindControl works on the 'current' NamingContainer.
Also, you won't get the DataItem in the ItemCommand.
HiddenField for what?? IF you want to update the 'object' and need the ID, get it from the DataKeys property (set DataKeyNames property on the ListView in the first place).
Jul 18, 2010 07:12 PM|nkour|LINK
thk you all. thanks pete I've found
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listview.itemcommand.aspx should help