【发布时间】:2014-03-07 13:23:15
【问题描述】:
我正在尝试将文本框绑定到 C# 中的下拉列表。我无法绑定文本框和下拉列表。
帮我看看这段代码
public void BindDropDownListData()
{
String strConnString = ConfigurationManager.ConnectionStrings["sample11"].ConnectionString;
using (SqlConnection mySqlConnection = new SqlConnection(strConnString))
{
try
{
mySqlConnection.Open();
SqlCommand mySqlCommand = new SqlCommand("dbo.SCM_JOB_DISPLAY", mySqlConnection);
mySqlCommand.CommandType = CommandType.StoredProcedure;
SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter(mySqlCommand);
DataSet myDataSet = new DataSet();
mySqlDataAdapter.Fill(myDataSet);
DropDownList1.DataSource = myDataSet;
DropDownList1.DataTextField = "HTTIS_Issue_Number";
DropDownList1.DataValueField = "HTTIS_Job_Code";
DropDownList1.DataBind();
}
catch (Exception ex)
{
Label1.Text = ex.Message;
}
finally
{
mySqlConnection.Close();
}
}
}
【问题讨论】:
-
您在哪里将文本框与此代码中的下拉列表绑定。
-
@Irfan 我们尝试了很多绑定代码,但我们收到了错误消息。所以目前我正在等待绑定文本框的帮助
-
那是什么意思..“将文本框绑定到下拉菜单”。显示您尝试过的内容,这将告诉您您正在尝试做什么。
标签: c# asp.net drop-down-menu filtering