我的数据记录表有以下数据:如果我请从下拉列表中的相应值应在文本框中显示值
Name Shiftname operatorname date Plantname Line Machine
Ashwini Shift1(7-3) Operator 1 2011-05-24 Plant 1 Line1 mc1
Deepika Shift2(3-11) Operator 2 2011-05-24 Plant 2 Line3 mc5
Pradeepa Shift2(11-7) Operator 3 2011-05-25 Plant 3 Line5 mc10
Deepika Shift1(7-3) Operator 1 2011-05-25 Plant 1 Line1 mc1
我提供2下拉列表即线和移位和一个文本框存储日期,如果用户从日历选择日期和两个文本框来存储工厂和操作员名称的值。
为例如,如果从压延用户选择线和移位从下拉列表和日期的相应plantname和operatorname应当在文本框中为前 可以dispalyed如果从下拉列表和SHIFT1用户选择第1行从下拉列表和日期具有25/05/2011两个文本框应该dispaly值有plant1和操作员1
我已经写代码低于:
protected void ddlline_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("connection string");
con.Open();
DataTable dt = new DataTable();
SqlCommand sqlCmd = new SqlCommand("SELECT distinct plantname,operatorname FROM datalogging1 WHERE Line='" + ddlline.SelectedItem + "'and date='"+txtdate.Text+"'and shiftname='"+ddlshift.SelectedItem+"'", con);
SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);
sqlDa.Fill(dt);
if (dt.Rows.Count > 0)
{
//Where ColumnName is the Field from the DB that you want to display
txtplant.Text = dt.Rows[0]["Plantname"].ToString();
txtop.Text = dt.Rows[0]["operatorname"].ToString();
}
}
,但它没有显示。
贵DataTable包含数据的详细信息? – 2011-06-03 05:10:09
你可以请尝试使用SelectedValue而不是SelectedItem? – Deepesh 2011-06-03 05:10:19
@abdul:雅与如果从下拉列表中选择刚刚行一个下拉列表和IM不检查日期还有其dispalying数据的到来,但是当我想根据路线,转向选择数据和日期的不来的Web应用程序。 – Sweety 2011-06-03 06:53:14