Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 多复选框列表_C#_Asp.net_Checkboxlist - Fatal编程技术网

C# 多复选框列表

C# 多复选框列表,c#,asp.net,checkboxlist,C#,Asp.net,Checkboxlist,我有一个多复选框列表,当我选择值时,数据应该显示在网格中。 我这里的问题是,每当我选择多个数据时,只会显示列表中第一个名称的详细信息 请帮帮我 这是我使用的代码 protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e) { txtSelect.Text = ""; for (int c = 0; c < CheckBoxList1.Items.Count; c++)

我有一个多复选框列表,当我选择值时,数据应该显示在网格中。 我这里的问题是,每当我选择多个数据时,只会显示列表中第一个名称的详细信息 请帮帮我

这是我使用的代码

 protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e)
 {
      txtSelect.Text = "";
      for (int c = 0; c < CheckBoxList1.Items.Count; c++)
      {
            if (CheckBoxList1.Items[c].Selected)
            {
                txtSelect.Text += CheckBoxList1.Items[c].Text + ";" + "" + "";
            }
        }
  }
protectedvoid CheckBoxList1\u SelectedIndexChanged(对象发送方,事件参数e)
{
txtSelect.Text=“”;
对于(int c=0;c
这就是我绑定数据的方式

" SelectCommand=“sp\u LeMS\u DDL\u Report”SelectCommandType=“StoredProcess”>
一种可能的方法是确保

AutoPostBack = true 
在您的复选框列表中,以便您的网页可以在更改后重新加载所有数据。然后,每次更改选择时,都应在

if(isPostBack)

将触发。然后,您可以将所选值添加到gridview数据源的insert或update语句中。

如何以及在何处将数据绑定到
复选框列表1
?如果要在页面加载时绑定复选框列表,请使用
if(!isPostBack){
请告诉我们您将在何处绑定复选框列表我希望当用户在多个复选框中不断选择时触发此事件。到目前为止,我的问题是,如果选中了两个名称,则复选框列表中会显示两个名称,只有第一个名称的详细信息会填充到网格中。我需要bo的两个详细信息要填充的名称。用于报告。抱歉,如果我没有回答您的问题,我是一名编程新手,请帮助我。ThanksHi@Ashwin,您能显示一下,您将数据绑定到CheckBoxList1的位置吗。它将是这样的-CheckBoxList1.DataSource=YourDataSource;CheckBoxList1.DataBind();