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.
2 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Vipan SharmaPosted Feb 27, 2016, 5:56 AM
It's a trick. I have used many time with the help of Ternary operator. Its work for me.
Set Visible true false of link button.
Note: Make Sure Syntax of link button is correct. I have not check syntax.
Kindly let me know if any help required.
Accept if it will help you
Happy Coding !!!!
Shubham KumarPosted Feb 27, 2016, 3:30 AM