I need to check whether the cells of a particular column in gridview has certain values. If the cells contain values it should do some action. I have attached my code.
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (TextBox1.Text != "")
{
if ((e.Row.Cells[3].Text == "1") && (e.Row.Cells[3].Text == "2"))
{
Label3.Visible = true;
}
}
}
}
It is not checking the AND condition. If i replace it by OR statement it works
ashwini patelPosted Sep 5, 2018, 12:44 AM
{
string n = GridView1.Rows[0].Cells[3].Text;
string m = GridView1.Rows[1].Cells[3].Text;
if (n == "1" && m == "2" )
{
Label3.Visible = true;
}
else
{
Label3.Visible = false;
}
}
Rafnas T PPosted Sep 4, 2018, 11:43 PM
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (TextBox1.Text != "")
{
if ((e.Row.Cells[3].Text == "1") && (e.Row.Cells[3].Text == "2"))
{
Label3.Visible = true;
}
ashwini patelPosted Sep 4, 2018, 11:17 PM
{
if (TextBox1.Text != "")
{
string Value1 = e.Row.Cells[3].Text;
string str = System.Text.RegularExpressions.Regex.Replace(Value1, @"[.\D+]", "");
int x = Convert.ToInt32(str);
if (Enumerable.Range(1, 2).Contains(x))
{
Label3.Visible = true;
}
else
{
Label3.Visible = false;
}
}
}
Nikunj SatasiyaPosted Sep 4, 2018, 6:38 AM
ashwini patelPosted Sep 4, 2018, 6:11 AM
ashwini patelPosted Sep 4, 2018, 5:05 AM
{
string Value1 = e.Row.Cells[3].Text;
string Value2 = e.Row.Cells[3].Text;
if (Value1 == "1" && Value2 == "2")
{
Label3.Visible = true;
}
if (e.Row.Cells[3].Text == "3")
{
Label5.Visible = true;
}
}
ashwini patelPosted Sep 4, 2018, 3:29 AM