Hello,
with Infragistics v14.2 I am not able to find a servercontrol inside a TemplateDataField. My ASPX-Code looks like this:
<ig:WebDataGrid ID="wdgData" runat="server" EnableViewState="True" EnableDataViewState="True" DataKeyFields="Product" AutoGenerateColumns="false"> <Columns> <ig:BoundDataField Key="Prodduct" DataFieldName="Product" Header-Text="Product"></ig:BoundDataField> <ig:TemplateDataField Key="Comment"> <ItemTemplate> <asp:TextBox ID="txtComment" runat="server"></asp:TextBox> </ItemTemplate> </ig:TemplateDataField> </Columns> </ig:WebDataGrid>
The grid is filled on PageLoad and shows the data as expected. However when I click an ASP.NET - Button my code is not able to get the TextBox. The code looks like this:
void btnButton_Click(object sender, EventArgs e) { foreach (Infragistics.Web.UI.GridControls.GridRecord r in wdgData.Rows) { TextBox textbox = (TextBox)r.Items[0].FindControl("txtValue");
if (textbox != null) // -> always null { //Do something with the textboxvalue }
} }
The project is configured to use .NET 4.5. If I set up a project using .NET 3.5 and Infragistics v12.2 my code is running fine and working as expected. Is there anything that has changed from v12.2 to v14.2?
Thank you for the update. I have logged this with our development team for further investigation with the id 189641. I have also created a private case where I will provide you with further information. The case number is CAS-151764-G7Y2B1.
Hi Mike,
here is an isolated example. I have attached a zip containing two folders. One folder for ASP.NET 3.5. I used IG 12.2.20122.2257. The other folder contains the files for use in an ASP.NET 4.5 Project (IG 14.2.20142.1028). Each folder contains the web.config, default.aspx, default.aspx.cs and default.aspx.designer.cs.
The 3.5 version is developed under VS 2010 and runs as expected, the 4.5 version is developed under VS 2013 and is NOT working as expected (-> Textbox not found)
Hope this help
Thank you for the update. I have done some looking into this matter and I have been unable to reproduce the behavior you see. I am able to use the following code to get the control in the template:
Image img = (Image)WebDataGrid1.Rows[0].Items[3].FindControl("IconImage");
I am attaching my sample, note I have removed the ig_res folder to be able to attach to the forum thread. Please run the sample and let me know what you see. Do you have an isolated sample that you can provide me with that reproduces this behavior?
I'm sorry, this was just a copy-paste-error. In my code the name equals "txtComment".
So this does not work:
void btnButton_Click(object sender, EventArgs e){ foreach (Infragistics.Web.UI.GridControls.GridRecord r in wdgData.Rows) { TextBox textbox = (TextBox)r.Items[0].FindControl("txtComment");
}}
Thank you for contacting Infragistics!
I have done some looking into this matter and I believe you are unable to get the textbox because of the id you are trying to find it by. You are trying to find it by “txtValue” when in your markup you have the textbox have the ID of “txtComment”
What happens when you use “txtComment” to find the textbox?
Please let me know if you have any questions concerning this matter.