Hello Sir,
I'm trying to update the gridview column based on query result, but the query is giving the last row in result and the gridview is not getting updated.
Please help me
Below is the code which im trying
SqlCommand cmd = new SqlCommand("Select preferredname from client_tbl_customer where rowstate=1 and status='Discharged'", con);
SqlDataAdapter da1 = new SqlDataAdapter(cmd);
DataTable dt1 = new DataTable();
da1.Fill(dt1);
if (dt1.Rows.Count > 0)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
int i = 0;
foreach (DataRow dr in dt1.Rows)
{
client_name = dr[0].ToString();
GridViewRow row = e.Row;
TableCell cell = e.Row.Cells[2];
string status = cell.Text;
for (int i1 = 0; i1 < GridView1.Columns.Count; i1++)
{
if (status == client_name)
{
LinkButton lb1 = (LinkButton)e.Row.FindControl("LinkButton1");
lb1.Visible = false;
}
}
}
i++;
}
}
Expected result: If the client name matches the gridview column(status) then linkbutton should be invisible
Please help me
Thanks