Hi,
I have placed a table in an edit form that contains validation on several textboxes. I'm trying to make the validation message to be right in the cell that contains the textbox. It seems like if I'm doing soemthing like the code below in my ItemCommand event, the message would be in the "outer" table cell. How do I access the table cell that's in the table within the <FormTemplate>?
I have placed a table in an edit form that contains validation on several textboxes. I'm trying to make the validation message to be right in the cell that contains the textbox. It seems like if I'm doing soemthing like the code below in my ItemCommand event, the message would be in the "outer" table cell. How do I access the table cell that's in the table within the <FormTemplate>?
<EditFormSettings EditFormType="Template"> <EditColumn FilterControlAltText="Filter EditCommandColumn1 column" UniqueName="EditCommandColumn1"> </EditColumn> <FormTemplate> <table class="auto-style1" border="2" > <tr> <td style="width:8%">Building Name:</td> <td style="width:8%"> <asp:TextBox ID="bldgname" runat="server" MaxLength="40" > </asp:TextBox> </td> <td style="width:8%">Column3</td> <td style="width:100%">Column4</td> </tr> <tr> <td>Address:</td> <td> <asp:TextBox ID="address1" runat="server" Text='<%# Bind("bldgstreet1") %>'></asp:TextBox><br /> <asp:TextBox ID="address2" runat="server" Text='<%# Bind("bldgstreet2") %>'></asp:TextBox><br /> </td> <td> </td> <td> </td> </tr> <tr> <td>City:</td> <td> <asp:TextBox ID="bldgcity" runat="server" Text='<%# Bind("bldgcity") %>'></asp:TextBox><br /> </td> <td> </td> <td> </td> </tr> <tr> <td>State:</td> <td> <asp:TextBox ID="bldgstate" runat="server" Text='<%# Bind("bldgstate") %>'></asp:TextBox><br /> </td> <td> </td> <td> </td> </tr> <tr style="width:5%; height:50px"> <td>Zip:</td> <td> <asp:TextBox ID="bldgzip" runat="server" Text='<%# Bind("bldgzip") %>'></asp:TextBox><br /> </td> <td> <div> <table width="100%"> <tr> <td style="width:30%"> <asp:ImageButton ID="CertifyAddressImageButton" runat="server" ImageUrl="~/images/certificate32.png" OnClick="CertifyAddressImageButton_Click"/> </td> <td style="width:70%"> <asp:CheckBox ID="CheckBoxOverride" runat="server" Text="Override?" TextAlign="Left" Font-Size="Large" /> </td> </tr> </table> </div> </td> <td> <telerik:RadComboBox ID="WireCenterRadComboBox" Runat="server" Height="200px" Width="200px" DropDownWidth="750px" HighlightTemplatedItems="True" MarkFirstMatch="True" EnableLoadOnDemand="True" Filter="StartsWith" EmptyMessage="Enter WireCenter Name..." ToolTip="Enter WireCenter Name to Filter list" OnItemsRequested="WireCenterRadComboBox_ItemsRequested" OnLoad="WireCenterRadComboBox_Load"> <HeaderTemplate> <table style="width: 700px" cellspacing="0" cellpadding="0"> <tr> <td style="width: 80px;">WireCenter</td> <td style="width: 150px;">Name</td> <td style="width: 150px;">T1OrderMethod</td> <td style="width: 100px;">Vendor ACTL</td> <td style="width: 170px;">Logix ACTL</td> </tr> </table> </HeaderTemplate> <ItemTemplate> <table style="width:700px" cellspacing="0" cellpadding="0"> <tr> <td style="width: 80px;"><%# DataBinder.Eval(Container, "Text")%></td> <td style="width: 150px;"><%# DataBinder.Eval(Container, "Attributes['wirecentername']")%></td> <td style="width: 150px;"><%# DataBinder.Eval(Container, "Attributes['t1ordermethod']")%></td> <td style="width: 100px;"><%# DataBinder.Eval(Container, "Attributes['vendoractl']")%></td> <td style="width: 170px;"><%# DataBinder.Eval(Container, "Attributes['logixactl']")%></td> </tr> </table> </ItemTemplate> </telerik:RadComboBox> </td> </tr> <tr> <td> <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'> </asp:Button> <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel"></asp:Button> </td> <td> </td> <td> </td> <td> </td> </tr> </table> </FormTemplate></EditFormSettings>if (e.CommandName == RadGrid.UpdateCommandName || e.CommandName == RadGrid.PerformInsertCommandName){ GridEditableItem item = e.Item as GridEditableItem; // Validate Zip Code RegularExpressionValidator validZip = new RegularExpressionValidator(); // for Accessing boundcolumn GridTextBoxColumnEditor editor; // Test zip TextBox txtbx; TableCell cell; txtbx = (TextBox)item.FindControl("bldgzip"); cell = ((GridEditFormItem)txtbx.NamingContainer).EditFormCell; validZip.ControlToValidate = txtbx.ID; validZip.ErrorMessage = "only [0-9] and '-' are allowed"; validZip.ValidationExpression = @"^\d{5}(-\d{4})?$"; validZip.ForeColor = System.Drawing.Color.Red; cell.Controls.Add(validZip); // End Test Zip validZip.Validate(); }