如果单选按钮为true,则显示gridview [英] display gridview if radiobutton checked true
本文介绍了如果单选按钮为true,则显示gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果radiobutton == true,则显示gridview
其他
没有gridview
请给我发代码
display gridview if radiobutton==true
else
no gridview
please send me the code
推荐答案
仅当您的gridview有项目时,它才可见.因此,如果单选按钮选中= false,则将gridview数据源设置为null
Only if your gridview have items, it will be visible.So if radiobutton checked =false, set gridview datasource to null
if (radioButton1.Checked)
{
Gridview1.Datasource=//something;
Gridview1.DataBind();
}
else
{
Gridview1.DataSource=null;
Gridview1.DataBind();
}
这是一个基本问题.您应该通过搜索Google并阅读一些文章来尝试一下.无论如何,请尝试使用此方法,下次再尝试使用google:
ASPX:
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:radiobutton id="btnCheck" runat="server" autopostback="true" oncheckedchange="btnCheck_CheckedChange" xmlns:asp="#unknown" />
<asp:gridview id="gvTest" runat="server" xmlns:asp="#unknown" />
CS:
CS:
protected void btnCheck_CheckChanged(object sender, EventArgs e)
{
if(btnCheck.Checked){
gvTest.DataSource = dt;
gvTest.DataBind();
}
else
{
gvTest.DataSource=null;
gvTest.DataBind();
}
}
祝一切顺利.
--Amit
All the best.
--Amit
这篇关于如果单选按钮为true,则显示gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文