Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
175
Validator in RowEditTemplate
posted

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.

Parents
  • 7694
    posted

     

    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&nbsp;

                            <input runat="server" id="igtbl_TextBox_0_0" columnkey="AddressesID" style="width: 150px;"

                                type="text">

                                <br>Address&nbsp;

                                    <input runat="server" id="igtbl_TextBox_0_1" columnkey="Address" style="width: 150px;"

                                        type="text">

                                        <br>PersonID&nbsp;

                                            <input id="igtbl_TextBox_0_2" runat="server" columnkey="PersonID" style="width: 150px;"

                                                type="text">

                                                <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"

                                                    ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>

                                            </input>

                                            <br></br>

                                        </br>

                                    </input>

                                    <br></br>

                                </br>

                            </input>

                            <br>

                                <p align="center">

                                    <input id="igtbl_reOkBtn" onclick="igtbl_gRowEditButtonClick(event);" style="width: 50px;"

                                        type="button" value="OK"> &nbsp;

                                        <input id="igtbl_reCancelBtn" onclick="igtbl_gRowEditButtonClick(event);" style="width: 50px;"

                                            type="button" value="Cancel"> </input>

                                    </input>

                                </p>

                                <br></br>

                            </br>

                        </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";

     } 

Reply Children