简体   繁体   English

在RadioButtonList中选择一个项目,如何从asp.net中的数据库获取到ListBox的项目列表c#

[英]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. 我在这里面临的问题是选择一个项目时,我放置了RadioButtonListListBox的整个面板都不可见。

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.

相关问题 从ASP.NET C#中的另一个下拉列表中选择项目后如何将项目加载到下拉列表中 - How to load items into dropdownlist after selecting item from another dropdownlist in asp.net c# 表中的C#ASP.Net RadioButtonList: <td> 边界也创建边界清单项 - C# ASP.Net RadioButtonList within table: <td> border also creating border arount LIST ITEMS ASP.NET C#如何通过从数据库检索的字符串动态选择按文本列出项目 - ASP.NET C# How to Select List Item by Text dynamically through string retrieved from database 如何使用C#在ASP.NET中一一获取列表框中的项目 - how to get the items in listbox one by one in asp.net using c# 我如何在ASP.NET C#的列表框项目之间获取空格 - how can i get spaces between listbox items in asp.net c# 如何访问ASP.NET中的RadioButtonList项目? - How to access RadioButtonList items in ASP.NET? 如何将项目添加到ListBox或XML中的另一个控件? ASP.Net(C#) - How to add items to ListBox or another control from XML? ASP.Net(C#) 如何从asp.net的列表框中获取所选项目? - How to get selected item from listbox in asp.net? asp.net:如何从会话手动(c#)在gridview内的单选按钮列表中选择单选按钮 - asp.net: How to manually (c#) select radiobutton in radiobuttonlist inside gridview from Session ASP.NET从Radiobuttonlist获得价值 - ASP.NET Get value from Radiobuttonlist
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM