gridview上的文本框条件 [英] textbox condition on gridview
本文介绍了gridview上的文本框条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在GridView中有一个用于标记条目的TextBox,我想检查条件,如果操作员输入大于满标记的标记,则显示错误信息。
我的网格视图那样
Sl。 No. StudentID RegistrationNo RollNo Full Marks输入标记
1 1 110001001 11000101 100 TextBox
2 2 110001002 11000102 100 TextBox
I have a TextBox in GridView for Marks Entry and I want to check condition that if operator enter Marks greater than full marks it display error message.
My GridView Like That
Sl. No. StudentID RegistrationNo RollNo Full Marks Enter Marks
1 1 110001001 11000101 100 TextBox
2 2 110001002 11000102 100 TextBox
推荐答案
尝试这样一个
Try like this one
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="Must be less than or equal to 100" Operator="LessThanEqual" Type="Integer" ValueToCompare="100" />
问候..:笑:
Regards.. :laugh:
你告诉文本框在gridview内。
我希望操作员只在编辑模式下输入标记,并且只能在更新模式下进行检查。
所以你最好试试这样的
you told that the textbox is inside the gridview.
I hope the operator will enter the marks during edit mode only and check can be made during the update mode only.
So you better try like this
GridViewRow UpdateRow = gvMarkList.Rows[e.RowIndex];
TextBox txtEnteredMarks= (TextBox)UpdateRow.FindControl("txtMarks");
if (txtEnteredMarks.Text. > "100")
{
// Show your error
}
else
{
// do your operation like update the data
}
希望有帮助...
Hope it helps...
这篇关于gridview上的文本框条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文