Click here to Skip to main content
15,888,301 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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"
Posted

1 solution

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;  
}
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900