B
BEN
Hi,
I want to add a custom validator to a dataGrid's boundcolumn. I use
datagrid's "edit, update, cancel" button to do. But I cannot find a method
to add the validator to boundcolumn.
In other way, I try to use TemplateColumn and EditItemTemplate with custom
validator. But I cannot bind the value to each corresponding column. All
values in the column are the same. The code is shown as below.
<asp:BoundColumn DataField="CustomerID" SortExpression="CustomerID"
HeaderText="CustomerID"></asp:BoundColumn>
<asp:BoundColumn Visible="False" DataField="EmployeeID"
SortExpression="EmployeeID" HeaderText="EmployeeID"></asp:BoundColumn>
<asp:BoundColumn DataField="Freight" SortExpression="Freight"
HeaderText="Freight"></asp:BoundColumn>
<asp:TemplateColumn SortExpression="OrderDate" HeaderText="OrderDate">
<ItemTemplate>
<%# DataBinder.Eval(DataSet11,
"Tables[Orders].Defaultview.[0].OrderDate", "{0:d}") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id=TextBox1 runat="server" Text='<%#
DataBinder.Eval(DataSet11, "Tables[Orders].OrderDate", "{0:d}") %>'>
</asp:TextBox>
<asp:CustomValidator id=CustomValidator2 runat="server"
ErrorMessage='<%# DataBinder.Eval(DataSet11,
"Tables[Orders].DefaultView.[0].OrderDate", "{0:d}")
%>'>*</asp:CustomValidator>
</EditItemTemplate>
</asp:TemplateColumn>
What is the best way to validate a value in dataGrid? Or use other server
control?
Thanks in advance.
I want to add a custom validator to a dataGrid's boundcolumn. I use
datagrid's "edit, update, cancel" button to do. But I cannot find a method
to add the validator to boundcolumn.
In other way, I try to use TemplateColumn and EditItemTemplate with custom
validator. But I cannot bind the value to each corresponding column. All
values in the column are the same. The code is shown as below.
<asp:BoundColumn DataField="CustomerID" SortExpression="CustomerID"
HeaderText="CustomerID"></asp:BoundColumn>
<asp:BoundColumn Visible="False" DataField="EmployeeID"
SortExpression="EmployeeID" HeaderText="EmployeeID"></asp:BoundColumn>
<asp:BoundColumn DataField="Freight" SortExpression="Freight"
HeaderText="Freight"></asp:BoundColumn>
<asp:TemplateColumn SortExpression="OrderDate" HeaderText="OrderDate">
<ItemTemplate>
<%# DataBinder.Eval(DataSet11,
"Tables[Orders].Defaultview.[0].OrderDate", "{0:d}") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id=TextBox1 runat="server" Text='<%#
DataBinder.Eval(DataSet11, "Tables[Orders].OrderDate", "{0:d}") %>'>
</asp:TextBox>
<asp:CustomValidator id=CustomValidator2 runat="server"
ErrorMessage='<%# DataBinder.Eval(DataSet11,
"Tables[Orders].DefaultView.[0].OrderDate", "{0:d}")
%>'>*</asp:CustomValidator>
</EditItemTemplate>
</asp:TemplateColumn>
What is the best way to validate a value in dataGrid? Or use other server
control?
Thanks in advance.