我在网页中添加了一个RadioButtonList控件,添加了两个Text值分别是“所有提问”和“我的问题”。代码如下:<asp:RadioButtonList ID="RadioButtonList1" runat="server"AutoPostBack="True"RepeatColumns="2">
<asp:ListItem Value="1">所有提问</asp:ListItem>
<asp:ListItem Value="2">我的问题</asp:ListItem>
</asp:RadioButtonList>启用的RadioButtonList为true在aspx.cs页面中添加代码如下:
protected void Page_Load(object sender, EventArgs e)
{
string condition = this.RadioButtonList1.Items[this.RadioButtonList1.SelectedIndex].Value; if (!IsPostBack)
{
if (condition = 1)
{
QuestionManager qm = new QuestionManager();
rptNewNews.DataSource = qm.SelectAllQuestion();
rptNewNews.DataBind();
}
else
{
QuestionManager qm = new QuestionManager();
rptNewNews.DataSource = qm.SelectByZjID(int.Parse(Request.QueryString["ZjID"]));
rptNewNews.DataBind();
} }
}在if (condition = 1)处出错,
错误提示为:无法将int转换为string,
我想知道如何通过RadioButtonList的value值写上面的if语句,实现通过点击RadioButtonList使Repeater控件中显示出不同的类容,
<asp:ListItem Value="1">所有提问</asp:ListItem>
<asp:ListItem Value="2">我的问题</asp:ListItem>
</asp:RadioButtonList>启用的RadioButtonList为true在aspx.cs页面中添加代码如下:
protected void Page_Load(object sender, EventArgs e)
{
string condition = this.RadioButtonList1.Items[this.RadioButtonList1.SelectedIndex].Value; if (!IsPostBack)
{
if (condition = 1)
{
QuestionManager qm = new QuestionManager();
rptNewNews.DataSource = qm.SelectAllQuestion();
rptNewNews.DataBind();
}
else
{
QuestionManager qm = new QuestionManager();
rptNewNews.DataSource = qm.SelectByZjID(int.Parse(Request.QueryString["ZjID"]));
rptNewNews.DataBind();
} }
}在if (condition = 1)处出错,
错误提示为:无法将int转换为string,
我想知道如何通过RadioButtonList的value值写上面的if语句,实现通过点击RadioButtonList使Repeater控件中显示出不同的类容,
解决方案 »
- asp.net后台怎么获取jquery动态生成的html控件值。
- 在解决方案资源管理器中没有bin文件夹?
- 求一个只能输入正整数或者带4位小数的正则表达市
- 分享经验,做一个好用扩展性好的网站管理系统
- 过滤<script>
- 关于VS.net开发平台的问题
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!求asp.net报表打印控件!!!!!!形成后向table那样的,有翻页,打印等功能。
- 一个奇怪的问题,请指教!
- 关于动态查询的问题!(高分,欢迎高手提供思路或源码)
- VS2013 MVC5程序无法启动。各位帮忙看看怎么解决
- C#怎样取MS SQL 数据库中以 '|'分隔的字符串?
- ASP.NET网站上传到服务器后出现错误
改成
if (condition == 1)
if (condition == "1")
if (!IsPostBack)
{
string condition = this.RadioButtonList1.Items[this.RadioButtonList1.SelectedIndex].Value;
if (condition = 1)
{
}
else{
}