Aspx Design
<asp:TemplateField HeaderText="Reviewer Report" ItemStyle-CssClass="hs1" ItemStyle-Width="20px">
<ItemTemplate>
<asp:ImageButton ID="lnk_report" runat="server" Visible="false" CommandName="Select" ImageUrl="../images/editicon.png" OnClick="lnk_report_click" />
</ItemTemplate>
</asp:TemplateField>
c# code
protected void report()
{
//report button activation code
string statusname;
string cs = ConfigurationManager.ConnectionStrings["key"].ToString();
cn = new SqlConnection(cs);
cn.Open();
foreach (GridViewRow r1 in dgvGrid.Rows)
{
dr.Close();
Label lbid = (Label)r1.FindControl("LBLID");
ImageButton lnk1 = (ImageButton)r1.FindControl("lnk_report");
string k = "select * from table where ID='" + lbid.Text + "'";
cmd = new SqlCommand(k, cn);
dr = cmd.ExecuteReader();
while(dr.Read())
{
statusname = dr[6].ToString();
if (statusname == "APPROVE")
{
lnk1.Visible = true;
}
}
}
dr.Close();
}
<asp:TemplateField HeaderText="Reviewer Report" ItemStyle-CssClass="hs1" ItemStyle-Width="20px">
<ItemTemplate>
<asp:ImageButton ID="lnk_report" runat="server" Visible="false" CommandName="Select" ImageUrl="../images/editicon.png" OnClick="lnk_report_click" />
</ItemTemplate>
</asp:TemplateField>
c# code
protected void report()
{
//report button activation code
string statusname;
string cs = ConfigurationManager.ConnectionStrings["key"].ToString();
cn = new SqlConnection(cs);
cn.Open();
foreach (GridViewRow r1 in dgvGrid.Rows)
{
dr.Close();
Label lbid = (Label)r1.FindControl("LBLID");
ImageButton lnk1 = (ImageButton)r1.FindControl("lnk_report");
string k = "select * from table where ID='" + lbid.Text + "'";
cmd = new SqlCommand(k, cn);
dr = cmd.ExecuteReader();
while(dr.Read())
{
statusname = dr[6].ToString();
if (statusname == "APPROVE")
{
lnk1.Visible = true;
}
}
}
dr.Close();
}
No comments:
Post a Comment