2
Reply

Link button should be visble false in gridview

narasiman rao

narasiman rao

Feb 27 2016 2:39 AM
376
I have grigview as follows
Course                                Code          Days       Startdate        Enddate
Clickhere(Link Button)       ASM              5       05 May 2016 10 May 2016
Clickhere(Link Button)                                     12 May 2016 17 May 2016
Clickhere(Link Button)                                      21 May 2016 25 May 2016
I dont want 2nd row and third row link button in gridview because in gridview
Code(2nd column) second and thrid row code is empty.
Whenever empty in Code i do not want link button. i want to set visble false.
for that my code as follows in Gridview row databound
protected void gvRank_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton lnk= (LinkButton)e.Row.FindControl("LinkButton2");
TextBox text = (TextBox)e.Row.FindControl("Code");
if (text == null && lnk == null)
{
lnk.Visble = false;
}
else
{
lnk.Visible = True;
}
}
}
But in gridview output i get as follows
Course                      Code                 Days                 Startdate            Enddate
                                 ASM                     5                05 May 2016 10 May 2016
                                                                                 12 May 2016 17 May 2016
                                                                                 21 May 2016 25 May 2016
In course column all the link button are visible false. i want only the second row and third row link button only visible false.

Answers (2)