I have a gridview. when i click edit button it ll turn into a editable mode. i kept validation but not able to update.
Below is my code..
<asp:GridView ID="GridView1" runat="server"
ShowFooter="True" AutoGenerateColumns="false"
OnRowCommand="GridView1_RowCommand" OnRowDeleting="GridView1_RowDeleting"
OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating" DataKeyNames="Id"
>
<Columns>
<asp:TemplateField HeaderText="EDIT">
<EditItemTemplate>
<asp:ImageButton ID="imgbtnUpdate" runat="server" CommandName="Update" ToolTip="Update" ImageUrl="~/IMAGES/tick_green_big.gif " />
<asp:ImageButton ID="imgbtnCancel" runat="server" CommandName="Cancel" ToolTip="Cancel" ImageUrl="~/IMAGES/cancel.gif" />
</EditItemTemplate>
<ItemTemplate>
<asp:ImageButton ID="imgbtnEdit" runat="server" CommandName="Edit" ToolTip="Edit" ImageUrl="~/IMAGES/edit.jpeg" />
</ItemTemplate>
<FooterTemplate>
<asp:ImageButton ID="imgbtnAdd" runat="server" CommandName="Add" ToolTip="Add" ImageUrl="~/IMAGES/ADD.jpeg" />
</FooterTemplate>
</asp:TemplateField>
</Columns>
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:TemplateField HeaderText="Name">
<EditItemTemplate>
<asp:HiddenField ID="hdnId" runat="server" Value='<%# Bind("Id") %>' />
<asp:TextBox ID="txtname" runat="server" Text='<%#Eval("Name") %>' />
<asp:RegularExpressionValidator ID="regname" runat="server"
ErrorMessage="Enter characters" Display="Dynamic"
ControlToValidate="txtname" ValidationExpression="[a-zA-Z]" ForeColor="#993333"></asp:RegularExpressionValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:HiddenField ID="hdnId" runat="server" Value='<%# Bind("Id") %>' />
<asp:Label ID="lblname" runat="server" Text='<%#Eval("Name") %>' />
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtftrname" runat="server" />
</FooterTemplate>
</asp:TemplateField>
</Columns>
Text in Bold ---> regular expression i kept. update not working if i use validation. without validation code works fine.
Help me please...