Click here to Skip to main content
15,909,829 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
display gridview if radiobutton==true
else
no gridview
please send me the code
Posted

Only if your gridview have items, it will be visible.So if radiobutton checked =false, set gridview datasource to null

C#
if (radioButton1.Checked)
{
 Gridview1.Datasource=//something;
 Gridview1.DataBind();
}

else
{
 Gridview1.DataSource=null;
 Gridview1.DataBind();
}
 
Share this answer
 
v2
Hi,
This is a basic question. You should try it by searching google and reading some articles. Anyway try this and from next time try to use google:
ASPX:
ASP.NET
<asp:radiobutton id="btnCheck" runat="server" autopostback="true" oncheckedchange="btnCheck_CheckedChange" xmlns:asp="#unknown" />
<asp:gridview id="gvTest" runat="server" xmlns:asp="#unknown" />

CS:
C#
protected void btnCheck_CheckChanged(object sender, EventArgs e)
{
    if(btnCheck.Checked){
        gvTest.DataSource = dt;
        gvTest.DataBind();
    }
    else
    {
        gvTest.DataSource=null;
        gvTest.DataBind();
    }
}




All the best.
--Amit
 
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