| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 526 人关注过本帖
标题:错在那里,请高手给看看
只看楼主 加入收藏
shevchenkoka
Rank: 1
等 级:新手上路
帖 子:34
专家分:0
注 册:2005-3-27
收藏
 问题点数:0 回复次数:1 
错在那里,请高手给看看

今天讲的内容,本人觉得代码写的没有错,但是不知道为什么那个RadioButtonList在远行后就是显示不出来!请高手给看看! 源代码如下: using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Data.SqlClient; namespace votetxxy { /// <summary> /// WebForm1 的摘要说明。 /// </summary> public class WebForm1 : System.Web.UI.Page { protected System.Web.UI.WebControls.Label Label1; protected System.Web.UI.WebControls.Button Button1; protected System.Web.UI.WebControls.Button Button2; protected System.Web.UI.WebControls.RadioButtonList RadioButtonList1; int votetype=2; private void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 if(!this.IsPostBack) { SqlConnection cnn=new SqlConnection("server=.;database=wklhdt;uid=sa;pwd=189934;"); cnn.Open(); SqlCommand cmm=new SqlCommand("Select votetitle from votetitle where id="+this.votetype.ToString(),cnn); string votetitle=cmm.ExecuteScalar().ToString(); this.Label1.Text=votetitle; SqlCommand cmm1=new SqlCommand("select voteitemid,voteitem from voteitem where voteid="+this.votetype.ToString() ,cnn); SqlDataReader sdr=cmm1.ExecuteReader(); this.RadioButtonList1.DataSource=sdr; this.RadioButtonList1.DataTextField="voteitem"; this.RadioButtonList1.DataValueField="voteitemid"; this.RadioButtonList1.DataBind(); this.RadioButtonList1.SelectedIndex=1; sdr.Close(); cnn.Close(); } }

#region Web 窗体设计器生成的代码 override protected void OnInit(EventArgs e) { // // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。 // InitializeComponent(); base.OnInit(e); } /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load);

} #endregion } }

搜索更多相关主题的帖子: 源代码 using 
2005-09-28 20:36
wucf2004
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2005-9-10
收藏
得分:0 

这是我写的代码你看一下吧,希望对你有所帮助,不过我连接的是access using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Data.OleDb;

namespace denglu { /// <summary> /// WebForm1 的摘要说明。 /// </summary> public class WebForm1 : System.Web.UI.Page { protected System.Web.UI.WebControls.Label Label1; protected System.Web.UI.WebControls.RadioButtonList RadioButtonList1; protected System.Web.UI.WebControls.Button Button1; protected System.Web.UI.WebControls.Button Button2; public int i=1; private void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 if(!IsPostBack) { OleDbConnection conn=new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;data source='C:\Inetpub\wwwroot\denglu\bin\投票.mdb'; "); conn.Open(); OleDbCommand cmm=new OleDbCommand("select votetitle from votetitle where voteid="+this.i.ToString(),conn); this.Label1.Text=cmm.ExecuteScalar().ToString(); OleDbCommand cmm1=new OleDbCommand("select * from voteitem where voteid="+this.i.ToString(),conn); OleDbDataReader sdr=cmm1.ExecuteReader(); this.RadioButtonList1.DataSource=sdr; this.RadioButtonList1.DataTextField="votetext"; this.RadioButtonList1.DataValueField="voteitemid"; this.RadioButtonList1.DataBind(); sdr.Close(); conn.Close(); }

}


2005-10-18 09:42
快速回复:错在那里,请高手给看看
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014495 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved