如何在Telerick RadGrid GridDropDownColumn中添加需要字段验证?
<telerik:GridDropDownColumn DataField="DEPT_ID" DataSourceID="SqlDSDeptType"
EnableEmptyListItem="true" EmptyListItemText="None" EmptyListItemValue="0" HeaderText="Depatment Type" ListTextField="DEPT_NAME" ListValueField="DEPT_ID" UniqueName="DEPT_ID">
</telerik:GridDropDownColumn>`enter code here`
答案 0 :(得分:0)
我这样做已经有一段时间了,对我来说真的很好。
<telerik:GridTemplateColumn HeaderText="Depatment Type" UniqueName="DEPT_ID">
<ItemTemplate>
<asp:Label runat="server" ID="lblDeptName"
</ItemTemplate>
<EditItemTemplate>
<telerik:RadDropDownList runat="server" ID="comboDepts"
DataSourceID="SqlDSDeptType"
DataTextField="DEPT_NAME" DataValueField="DEPT_ID">
</telerik:RadDropDownList>
<asp:RequiredFieldValidator ID="rfvcomboDepts" runat="server"
Display="Dynamic" CssClass="validationClass"
ValidationGroup="grvgName"
ControlToValidate="comboDepts"
ErrorMessage="Department cannot be empty"></asp:RequiredFieldValidator>
</EditItemTemplate>
<InsertItemTemplate>
<telerik:RadDropDownList runat="server" ID="comboDepts"
DataSourceID="SqlDSDeptType"
DataTextField="DEPT_NAME" DataValueField="DEPT_ID">
</telerik:RadDropDownList>
<asp:RequiredFieldValidator ID="rfvcomboDepts" runat="server"
Display="Dynamic" CssClass="validationClass"
ValidationGroup="grvgName"
ControlToValidate="comboDepts"
ErrorMessage="Department cannot be empty"></asp:RequiredFieldValidator>
</InsertItemTemplate>
</telerik:GridTemplateColumn>
CSS
.validationClass {
background-color: #FFCCCC;
color: black;
font-weight: bold;
}