[英]Selecting an item in the RadioButtonList, how to get a list of items to a ListBox from database in asp.net c#
I have a RadioButtonList
and a ListBox
. 我有一个
RadioButtonList
和一个ListBox
。 I have bound RadioButtonList
to database. 我已将
RadioButtonList
绑定到数据库。 Therefore upon selecting an item in the RadioButtonList
, I want to retrieve some data into the ListBox
. 因此,在
RadioButtonList
选择一个项目后,我想将一些数据检索到ListBox
。 The code I have tried is : 我试过的代码是:
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();
}
The issue I am facing here is upon selecting an item, the whole panel in which I have placed both my RadioButtonList
and ListBox
goes invisible. 我在这里面临的问题是选择一个项目时,我放置了
RadioButtonList
和ListBox
的整个面板都不可见。
Kindly help...!! 请帮助...! Thankyou...!!
谢谢...!!
First, change Page_Load method as: 首先,将Page_Load方法更改为:
protected void Page_Load(object sender, EventArgs e)¨
{
if (!Page.IsPostBack)
{
RadioFill();
}
}
If it not help than post code from your *.aspx file. 如果这不是帮助* .aspx文件中的代码。
Remark: The method RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e), there is not selecting based on radio button list selected value. 备注:方法RadioButtonList1_SelectedIndexChanged(object sender,EventArgs e),没有基于单选按钮列表选择的选定值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.