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");
}}
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.
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.
Hi Mike,
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