我有一個RadioButtonList
和一個ListBox
。我已經綁定了RadioButtonList
到數據庫。 因此,在選擇RadioButtonList
中的項目後,我想要將一些數據檢索到ListBox
。我曾嘗試的代碼是:在RadioButtonList中選擇一個項目,如何從asp.net中的數據庫獲取一個ListBox項目列表c#
protected void Page_Load(object sender, EventArgs e)
{
RadioFill();
}
public void RadioFill()
{
SqlDataAdapter mydata = new SqlDataAdapter("SELECT DISTINCT Param_Name FROM Parameter_Value_Master", con);
DataSet dset = new DataSet();
mydata.Fill(dset, "Table");
RadioButtonList1.Items.Clear();
RadioButtonList1.DataSource = dset.Tables[0];
RadioButtonList1.DataTextField = dset.Tables[0].Columns["Param_Name"].ColumnName;
RadioButtonList1.DataBind();
}
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{
SqlDataAdapter mydata = new SqlDataAdapter("SELECT Value_Option FROM Parameter_Value_Master", con);
DataSet dset = new DataSet();
mydata.Fill(dset, "Table");
ListBox1.Items.Clear();
ListBox1.DataSource = dset.Tables[0];
ListBox1.DataTextField = dset.Tables[0].Columns["Value_Option"].ColumnName;
ListBox1.DataBind();
}
我面對這裏是在選擇項目的問題,整個面板中,我已經把我的兩個RadioButtonList
和ListBox
去無形。
請幫助...... !!謝謝...!!
你能不能展示你如何在你的aspx頁面中定義你的RadioButtonList1和ListBox1? – avi
我編輯了我的問題。 –
你的代碼似乎確定...你可以顯示該面板的代碼嗎?該小組如何定義這2個項目?或者它們是動態創建的? – avi