开发者

how to get data from listview as string C# asp.net

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.Get开发者_如何学编程Values("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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜