I watched the video training about putting some asp.net validator's in an UltraWebGrid and my question is that i can't find a way how to make them work when i use RowEditTemplate to insert/update data in the grid.
Hello,
When you select Edit Template for the first time, UltraWebGrid asks "Do you want to add a textbox and label for each visible column of the row?" if you select Yes then in RowEditTemplate HTML inputs are added but they are not in server mode (no runat="server" attribute is set) - hence they cannot be validated by server controls.
You can just set in <RowEditTemplate > tag of UltraWebGrid some validation and then set in all Textbox runat="server" - this will solve the problem. For example:
//Demo.aspx
....
<RowEditTemplate>
AddressesID
<input runat="server" id="igtbl_TextBox_0_0" columnkey="AddressesID" style="width: 150px;"
type="text">
<br>Address
<input runat="server" id="igtbl_TextBox_0_1" columnkey="Address" style="width: 150px;"
<br>PersonID
<input id="igtbl_TextBox_0_2" runat="server" columnkey="PersonID" style="width: 150px;"
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="igtbl_TextBox_0_1"
ErrorMessage="FieldRequiredValidator"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="igtbl_TextBox_0_2"
ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="igtbl_TextBox_0_0"
</input>
<br></br>
</br>
<br>
<p align="center">
<input id="igtbl_reOkBtn" onclick="igtbl_gRowEditButtonClick(event);" style="width: 50px;"
type="button" value="OK">
<input id="igtbl_reCancelBtn" onclick="igtbl_gRowEditButtonClick(event);" style="width: 50px;"
type="button" value="Cancel"> </input>
</p>
</RowEditTemplate>
//Demo.aspx.cs
...
using Infragistics.WebUI.UltraWebGrid;using System.Drawing;
protected void Page_Load(object sender, EventArgs e) {
UltraWebGrid1.Columns.Insert(0, "Edit"); UltraWebGrid1.Columns[0].Type = ColumnType.Button; UltraWebGrid1.Columns[0].Width = 50; UltraWebGrid1.Columns[0].CellButtonStyle.BackColor = Color.FromArgb(204, 0, 0); UltraWebGrid1.Columns[0].CellButtonStyle.BorderWidth = 1; UltraWebGrid1.Columns[0].CellStyle.BackColor = Color.FromArgb(51, 51, 51); UltraWebGrid1.Columns[0].CellButtonStyle.BorderColor = Color.FromArgb(204, 0, 0); UltraWebGrid1.DisplayLayout.Bands[0].Columns[0].Header.Caption = "Edit";
}