I am submitting inputs from gridview to database on button click. Here, I am checking if a particular column value is left blank or not on submit. If it is blank, I need to diplay an alert message with particular row number. i.e. if in row no 3 the col3 value is left blank and submitted, I should get message :Please fill col3 value in row no 3"
As of now I dont know how to display the row number.
This is my code :
for (int i = 0; i < GridView1.Rows.Count; i++)
{
Label col = (Label)GridView1.Rows[i].FindControl("col3");
if(col.Text == string.Empty)
{
StringBuilder s = new StringBuilder();
s.Append("<script language='javascript'>");
s.Append("alert(' Please fill col3 value!!')");
s.Append("</script>");
RegisterStartupScript("Please fill col3 value !!'", s.ToString());
}
else
{
// rest code
}
}