dropdownlist 绑定后,在页面中没有显示,是怎么回事?
代码如下:publicDataSetGetDataSet1(stringsqlStr,stringTableName){SqlConnectionmyConn=conn(...
代码如下:
public DataSet GetDataSet1(string sqlStr, string TableName)
{
SqlConnection myConn = conn();//创建连接对象
myConn.Open();//打开数据库连接
DataSet ds = new DataSet();
SqlDataAdapter adapt = new SqlDataAdapter(sqlStr, myConn);
adapt.Fill(ds, TableName);
myConn.Close();
return ds;
}
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
bindTopic();
}
}
public void bindTopic()
{
string sqlstr = "select * from vote";
Topic_List.DataSource = que.GetDataSet1(sqlstr, "vote");
Topic_List.DataTextField = "Name";
Topic_List.DataValueField = "Tid";
Topic_List.DataBind();
} 展开
public DataSet GetDataSet1(string sqlStr, string TableName)
{
SqlConnection myConn = conn();//创建连接对象
myConn.Open();//打开数据库连接
DataSet ds = new DataSet();
SqlDataAdapter adapt = new SqlDataAdapter(sqlStr, myConn);
adapt.Fill(ds, TableName);
myConn.Close();
return ds;
}
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
bindTopic();
}
}
public void bindTopic()
{
string sqlstr = "select * from vote";
Topic_List.DataSource = que.GetDataSet1(sqlstr, "vote");
Topic_List.DataTextField = "Name";
Topic_List.DataValueField = "Tid";
Topic_List.DataBind();
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询