Adding a validator to the gridview text box created in linked field edit mode

take a look at this code example: (question below)

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
    AllowSorting="True" DataSourceID="SqlDataSource2" 
    AutoGenerateColumns="False" onrowupdated="GridView1_RowUpdated" 
         DataKeyNames="Product_Id">
    <Columns>
    <asp:ImageField DataImageUrlField="Image_Name" HeaderText="Image_Name" 
           ReadOnly="True" >
    <ItemStyle Width="50px" Height="50px"  Wrap="true"/>
    </asp:ImageField>       
    <asp:BoundField DataField="Product_Id" HeaderText="Product_Id" 
           InsertVisible="False" ReadOnly="True" SortExpression="Product_Id">
    </asp:BoundField>
        <asp:BoundField DataField="Product_Name" HeaderText="Product_Name" 
            SortExpression="Product_Name" />
        <asp:BoundField DataField="Category_Name" HeaderText="Category_Name" 
            SortExpression="Category_Name" ReadOnly="true" />
        <asp:BoundField DataField="Description" HeaderText="Description" 
            SortExpression="Description" />
        <asp:BoundField DataField="Size" HeaderText="Size" 
                 SortExpression="Size" />
        <asp:BoundField DataField="Price" HeaderText="Price" 
                 SortExpression="Price" />
        <asp:CommandField ShowEditButton="True" />
        <asp:CommandField ShowDeleteButton="True" />
    </Columns>
</asp:GridView>

Suppose I initialize a SqlDataSource, add a parameter, etc.

The fact is that when the user clicks on editing, we get a text field for editing the colnumn value. I want to check the data entered by the user before the update is completed, and the new data is distributed back to the server. How?

10x a lot!

+2
source share
2 answers

You need to convert BoundField to TemplateField . You can then add the validator to the actual TextBox control.

+2

All Articles