下拉列表中没有值 [英] no value in dropdownlist
问题描述
未在下拉列表中显示值
和按钮错误
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屋!