浏览网格中的每个项目 [英] Go through Each item in a grid

查看:60
本文介绍了浏览网格中的每个项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个网格,我想添加一些验证,

我在每一列中有两个复选框和一个文本框,我使用每个loap来遍历每一列,主要是我想检查是否单击了复选框并且文本框中有数据,网页将向用户显示一条消息,当单击复选框并且文本框中包含数据时:感谢您的决定和如果文本框中没有数据显示消息你必须在文本框中输入数据这里的问题是它在第一次应用这个条件只意味着如果内部没有数据显示它显示的文本框:你必须在文本框中输入数据:但在第二次显示谢谢你的决定

I am working on a grid and I want to add some validations ,
I have in each column two check boxes and one text box , i use for each loap to go through each column ,Mainly I want to check if the check box is clicked and there is data inside the text box , the webpage will display a message to the user and when the check box is clicked and the text box has data :"thank you for your decisions" and if there is no data inside the text box show message "you have to enter data inside text box" the problem here is it applies this conditions at the first time only meaning if there is no data insider the text box it displays :you have to enter data inside text box: but in the second time it displays "thank you for your decisions"

推荐答案

Foreach(GridViewRow row in GridView1.Rows)
{
//Giving one demo
TextBox txt=(TextBox)row.FindControl("textBoxID");
if (txt.Text=="")
{
txt.ToolTip="you have to enter data inside text box";
txt.BorderColor=System.Drawing.Color.Red;
}
else {
txt.ToolTip="thank you for your decisions";
txt.BorderColor=System.Drawing.Color.Gray;  
}
}


这篇关于浏览网格中的每个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆