- Asp.net2.0页面的生命周期 (2)
- DTCMS自定义标签,tags分割
- 从零开始学习jQuery (九) jQuery工具函数
- C# 项目中 csproj 文件格式的本质和编译流程
- Asp.net(C#)给图片加上水印效果
- c#属性 [ApiExplorerSettings(IgnoreApi = true)]有什么作用?
- 怎样查看一个域名是否被惩罚过
- 老域名的优势是什么?为什么要用老域名建新站?
- c# 类中属性和方法
- 旅游网站解决方案
邮箱:
手机:15383239821
RadioButtonList绑定后的默认选项
投票程序,RadioButtonList绑定后,刚打开的页面RadioButtonList是没有选中的,怎么使页面一打开默认第一项被选中。
private void Page_Load(object sender, System.EventArgs e)
{
if(!this.IsPostBack)
{
SqlConnection con=DB.createCon();
con.Open();
SqlCommand cmd=new SqlCommand("select vTitle from vote where vID="+this.vID+"",con);
this.Label1.Text=Convert.ToString(cmd.ExecuteScalar());
// 在此处放置用户代码以初始化页面
SqlConnection con1=DB.createCon();
con1.Open();
SqlCommand cmd1=new SqlCommand("select vItemID,vItem from voteItem where vID="+this.vID+"",con1);
SqlDataReader sdr=cmd1.ExecuteReader();
this.RadioButtonList1.DataSource=sdr;
this.RadioButtonList1.DataTextField="vItem";
this.RadioButtonList1.DataValueField="vItemID";
this.RadioButtonList1.DataBind();
sdr.Close();
con1.Close();
}
}
回答: 加上this.RadioButtonList1.SelectedIndex = 0; //选中第一项
- 上一篇:将两个表数据绑定到一个GRIDVIEW中
- 下一篇:逻辑与运算符 &&
-
2013-03-13Css教程,如何把Css转为utf-8格式,样式表gb2312转utf-8图文教程
-
2012-07-02网站收录问题经验分享
-
2010-11-08简单的精华代码集
-
2023-04-10ThinkPHP6.0 入门2,url访问模式,控制器定义,基础、空、多级,验证
-
2012-07-02如何在百度知道留下你的链接.
-
2012-06-305大seo细节
