Click to See Complete Forum and Search --> : FindControl not working


Zolix2010
November 13th, 2004, 09:12 AM
hi,
i got this datagrid:

<asp:datagrid id="dataGrid1" runat="server" BorderStyle="Solid" Font-Names="Verdana" Font-Size="XX-Small" AllowSorting="True" AllowPaging="True">
<Columns>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update" CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn>
<asp:ButtonColumn Text="Delete" CommandName="Delete"></asp:ButtonColumn>
<asp:BoundColumn DataField="Id" HeaderText="Id"></asp:BoundColumn>
</Columns>
<PagerStyle Mode="NumericPages"></PagerStyle>
</asp:datagrid>


when i try to get the text from the ID column :

TextBox text = (TextBox)e.Item.FindControl("Id");
string a = text.Text;

i get nothing.

why is that?

mmetzger
November 13th, 2004, 05:25 PM
FindControl looks for controls with a certain ID. You haven't assigned one. Usually, findcontrol is used with template columns, but I guess boundcolumns, etc would work (still need to add id="name")