下拉列表中没有值 [英] no value in dropdownlist

查看:88
本文介绍了下拉列表中没有值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

未在下拉列表中显示值

和按钮错误







protected void DropDownList1_SelectedIndexChanged(object sender,EventArgs e)

{

string query =SELECT [Model],[SN] FROM [''ISB VAS Nodes $' '];

DataSet ds = new DataSet();

SqlDataAdapter da = new SqlDataAdapter(query,connstring);

da.Fill (ds);

if(ds.Tables [0] .Rows.Count> 0)

{

DropDownList1.DataSource = ds ;

DropDownList1.DataTextField =Model;

DropDownList1.DataValueField =sn;

DropDownList1.DataBind();

}



}



protected void Button1_Click(object sender,EventArgs e)

{

str ing searchTXt = GridView2.SelectedValue.ToString(); //在这一行中

string query =SELECT [Model],[SN] FROM [''ISB VAS Nodes $''];

DataSet ds = new DataSet();

SqlDataAdapter da = new SqlDataAdapter(query,connstring);

da.Fill(ds);

if(ds。表[0] .Rows.Count> 0)

{

GridView2.DataSource = ds;

GridView2.DataBind();

}

}

Not showing values in dropdownlist
and error in button



protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
string query = "SELECT [Model], [SN] FROM [''ISB VAS Nodes$'']";
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(query, connstring);
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
DropDownList1.DataSource = ds;
DropDownList1.DataTextField = "Model";
DropDownList1.DataValueField = "sn";
DropDownList1.DataBind();
}

}

protected void Button1_Click(object sender, EventArgs e)
{
string searchTXt = GridView2.SelectedValue.ToString(); //in this line
string query = "SELECT [Model], [SN] FROM [''ISB VAS Nodes$'']";
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(query, connstring);
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
GridView2.DataSource = ds;
GridView2.DataBind();
}
}

推荐答案

''];

DataSet ds = new DataSet();

SqlDataAdapter da = new SqlDataAdapter(query,connstring);

da.Fill(ds);

if(ds .Tables [0] .Rows.Count> 0)

{

DropDownList1.DataSource = ds;

DropDownList1.DataTextField =Model ;

DropDownList1.DataValu eField =sn;

DropDownList1.DataBind();

}



}



protected void Button1_Click(object sender,EventArgs e)

{

string searchTXt = GridView2.SelectedValue.ToString(); //在这一行

string query =SELECT [Model],[SN] FROM [''ISB VAS Nodes
'']";
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(query, connstring);
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
DropDownList1.DataSource = ds;
DropDownList1.DataTextField = "Model";
DropDownList1.DataValueField = "sn";
DropDownList1.DataBind();
}

}

protected void Button1_Click(object sender, EventArgs e)
{
string searchTXt = GridView2.SelectedValue.ToString(); //in this line
string query = "SELECT [Model], [SN] FROM [''ISB VAS Nodes


''];

DataSet ds = new DataSet();

SqlDataAdapter da = new SqlDataAdapter(query,connstring);

da.Fill(ds);

if(ds.Tables [0] .Rows.Count> 0)

{

GridView2.DataSource = ds;

GridView2.DataBind();

}

}
'']";
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(query, connstring);
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
GridView2.DataSource = ds;
GridView2.DataBind();
}
}


确保正确定义了连接字符串。

检查您的查询是否返回任何记录。



尝试调试源代码以跟踪按钮单击时的错误。
Make sure your connection string is correctly defined.
Check if your query returns any records.

Try debugging your source code to trace the error on button click.


这篇关于下拉列表中没有值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆