如何从列表视图中获取数据作为字符串 C# asp.net

发布于 2024-11-18 08:55:29 字数 1593 浏览 4 评论 0原文

我正在使用 C# 和 asp.net 2.0 来解决这个问题。 1) Webfrom1 包含文本框和员工搜索图像按钮。当我单击图像按钮时,会弹出employeelist.webforms。

2)在employeelistwebform,它包含filterby:(组合框),搜索按钮,两个列表视图, 确定按钮和取消按钮。 3)在listview1中,它将通过员工代码绑定过滤器。然后用户可以移动选定的员工代码。

4)点击确定后,我希望所选员工代码能够显示在Webform1的搜索图像按钮的文本框中,并自行关闭emplylistwebforms。

e   public void bttOK_Click(object sender, System.EventArgs e)
    {



        string ListlbAppGroup = Convert.ToString(Request.Form.GetValues("listName2"));
       // ListLbAppGroup is always null.I dont know how to get the selectedvalue  from   listview.
        string litPeriod = "";
        listName2.Items.Clear;
        LoadListEmployee();   

           if (Request.Form.GetValues("listName2")==null)
           {

              for (int i = 0; i <= ListlbAppGroup.Length - 1; i++)
               { 



                    //listName2.Items.Add(new ListItem (ListlbAppGroup[i].ToString().Split['|'][1],ListlbAppGroup[i].Split["|"][0]));

                    //listName.Items.Remove(new ListItem(ListlbAppGroup[i].Split['|'][1],ListlbAppGroup[i].Split["|"][0]));
                    //litPeriod+= ","+ListlbAppGroup[i];


                   listName2.Items.Add(new ListItem(ListlbAppGroup[i],ListlbAppGroup[i]));
                   listName2.Items.Remove(new ListItem(ListlbAppGroup[i],ListlbAppGroup[i]));
               }

           }
           txtPeriod.Value = litPeriod;
           Page.RegisterStartupScript("close", "<script language='javascript'>window.returnValue= '" + litPeriod + "';window.close();</script>");
    }nter code here

I am working with C# and asp.net 2.0 on this.
1) Webfrom1 contains text box and employee search image button. when i click image button, pop up with employeelist.webforms.

2) at employeelistwebform, it contains filterby:(combobox) ,search button, two listview,
Ok button and Cancle button.
3) at listview1 it'll bind filiterby employee code.Then uses are able to move the selected employee codes .

4)After that click Ok, i want that selected emplyeecodes able to show in the textbox of search image button at Webform1 and close employeelistwebforms byself.

e   public void bttOK_Click(object sender, System.EventArgs e)
    {



        string ListlbAppGroup = Convert.ToString(Request.Form.GetValues("listName2"));
       // ListLbAppGroup is always null.I dont know how to get the selectedvalue  from   listview.
        string litPeriod = "";
        listName2.Items.Clear;
        LoadListEmployee();   

           if (Request.Form.GetValues("listName2")==null)
           {

              for (int i = 0; i <= ListlbAppGroup.Length - 1; i++)
               { 



                    //listName2.Items.Add(new ListItem (ListlbAppGroup[i].ToString().Split['|'][1],ListlbAppGroup[i].Split["|"][0]));

                    //listName.Items.Remove(new ListItem(ListlbAppGroup[i].Split['|'][1],ListlbAppGroup[i].Split["|"][0]));
                    //litPeriod+= ","+ListlbAppGroup[i];


                   listName2.Items.Add(new ListItem(ListlbAppGroup[i],ListlbAppGroup[i]));
                   listName2.Items.Remove(new ListItem(ListlbAppGroup[i],ListlbAppGroup[i]));
               }

           }
           txtPeriod.Value = litPeriod;
           Page.RegisterStartupScript("close", "<script language='javascript'>window.returnValue= '" + litPeriod + "';window.close();</script>");
    }nter code here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

貪欢 2024-11-25 08:55:29

实际的 id 和html 中的控件名称可以与服务器端 ID 不同。您需要使用 UniqueID 属性来获取 html 中的控件名称 - 表单数据将针对该名称。因此,您的代码应该类似于

string[] selectedValues = Request.Form.GetValues(listName2.UniqueID);
// join the array to get comma separated string

或者,您也可以迭代 listName2.Items 集合并查看 Selected 属性是否为 true。

The actual id & name of the control in html can be different than the server side ID. You need to use UniqueID property to get the control name in the html - the form data will be against that name. So your code should be something like

string[] selectedValues = Request.Form.GetValues(listName2.UniqueID);
// join the array to get comma separated string

Alternately, you can also iterate over listName2.Items collection and see if Selected property is true or not.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文