Click here to Skip to main content
15,910,878 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In Gridview as follows


Room Course Room Course

11 Linkbtn 21 Linkbtn
12 Linkbtn 22 Linkbtn
13 Linkbtn 23 Linkbtn
14 Linkbtn 24 Linkbtn


i have one button called Hidelinkbutton. when i click that hidelinkbutton i want in Gridview all the Linkbtn to be visible false.



I tried my code as follows


protected void Hidelinkbutton_Click(object sender, EventArgs e)
{

GridView row = gvClassRooms.Rows[0];
((LinkButton)row.FindControl("lnkRoom1")).Visible = false;

GridView row = gvClassRooms.Rows[1];
((LinkButton)row.FindControl("lnkRoom1")).Visible = false;


GridView row = gvClassRooms.Rows[2];
((LinkButton)row.FindControl("lnkRoom1")).Visible = false;


GridView row = gvClassRooms.Rows[3];
((LinkButton)row.FindControl("lnkRoom1")).Visible = false;

}



when i run the above code shows error as follows,

Cannot implicitly convert type 'System.Web.UI.WebControls.GridViewRow' to 'System.Web.UI.WebControls.GridView'

the above code is not working.what is the problem in my above code.
please help me.

Regards,
Narasiman P.
Posted

try this

for(int i=0;i<gvclassrooms.rows.count;i++)>
{
LinkButton lnkBtn = (LinkButton)gvClassRooms.Rows[i].FindControl("lnkRoom1");
lnkBt.Visible = false;
}
 
Share this answer
 
 
Share this answer
 
use jquery to do this task you have three link buttons in gridview
C#
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script language="javascript">
$(document).ready(function(){
$(".hideit").click(function(){
$(".hide").hide();
});
});
</script>
</head>
<body>
 <form id="form1" runat="server">
<asp:gridview id="Grd" runat="server" autogeneratecolumns="false" xmlns:asp="#unknown">
<columns>
<asp:templatefield headertext="to be hide">
<asp:linkbutton id="lnktobeHideOne" runat="Server" text="to be hide" cssclass="hide" />
</asp:templatefield>
<asp:templatefield headertext="to be hide">
<asp:linkbutton id="lnktobeHide2" runat="Server" text="to be hide" cssclass="hide" />
</asp:templatefield>
<asp:templatefield headertext="to be hide">
<asp:linkbutton id="lnktobeHideOne" runat="Server" text="to be hide" cssclass="hideit" />
</asp:templatefield>
</columns>
</asp:gridview>

</body>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900