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 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.
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 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?
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 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.
Is there any update on this issue. We are facing same issue
We tried the following
CheckBox checkControl = (CheckBox)row.Items.FindItemByKey("FacultyKey").FindControl("FacultyCheckBox"); null
CheckBox checkControl = (CheckBox)row.Items[3].FindControl("FacultyCheckBox"); null
Whether this issues is fixed and released. If yes please let me know the service release number so that we can install
Hello Ramya,
To resolve this you will want to call EnsureTemplates on postback the reason for this that the templates are instantiated with the databind method of the WebDataGrid which if not called manually on Page_load will be called by the page lifecycle at a stage after the OnClick event. So since you have EnableDataViewState set to true you will want to call EnsureTemplates on postback instead of DataBind.
You have to use below method at pageload event and this is to be called every time
this.<YourGridName>EnsureTemplates();
How did you resolve the findcontrol problem Ramya. Can you paste the sample code. I'm also facing the same problem to access the textbox from codebehind.
Mike, can you also help with the sample code which is resolved?
Hello Mike,
Now the findcontrol problem is resolved. but My Grid has the checkbox and radio button, But i can't able to get the rows based on the checkboxes in the server side.Please help me how to resolve this. We need the solution for Radio button,check box and dropdown is not working properly.
Please help me how to proceed further or Is there latest service release to fix the issues.