日期:2014-05-18  浏览次数:20370 次

求教
con.Open();
                SqlCommand   cmd1   =   new   SqlCommand( "select   *   from   fie_VoteList ",   con);
                SqlDataReader   sad   =   cmd1.ExecuteReader();
                this.RadioButtonListVoteList.DataSource   =   sad;
                this.RadioButtonListVoteList.DataValueField   =   "VLid ";
                this.RadioButtonListVoteList.DataTextField   =   "VoteList ";
                this.RadioButtonListVoteList.DataBind();
                sad.Close();
                con.Close();

有错吗?
怎么什么都显示不出来

------解决方案--------------------
把SqlDataReader sad = cmd1.ExecuteReader();
换成DataSet sad = cmd1.ExecuteDataSet();
------解决方案--------------------
con.Open();
SqlCommand cmd1 = new SqlCommand( "select * from fie_VoteList ", con);
SqlDataReader sad = cmd1.ExecuteReader();
if(sad.Read())
{
this.RadioButtonListVoteList.DataSource = sad;
this.RadioButtonListVoteList.DataValueField = "VLid ";
this.RadioButtonListVoteList.DataTextField = "VoteList ";
this.RadioButtonListVoteList.DataBind();
}
sad.Close();
con.Close();

因为 DataReader 是只读向前的```

楼上的也是对的