Adding a validator to the gridview textbox, created in edit-mode of a bound field

Posted by user181218 on Stack Overflow See other posts from Stack Overflow or by user181218
Published on 2009-10-06T08:30:58Z Indexed on 2010/06/10 4:02 UTC
Read the original article Hit count: 186

Filed under:
|

Hi,take a look at this sample code: (question bellow)

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

Assume I initialize an SqlDataSource, add a parameter and so on.

The thing is, that when a user clicks edit we get a textbox to edit the colnumn value. I want to validate the data enter by the user before the update is performed and the new data is propagated back to the server.How?

10x a lot!

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about validators