如何从列表视图中获取数据作为字符串 C# asp.net
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际的 id 和html 中的控件名称可以与服务器端 ID 不同。您需要使用 UniqueID 属性来获取 html 中的控件名称 - 表单数据将针对该名称。因此,您的代码应该类似于
或者,您也可以迭代
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
Alternately, you can also iterate over
listName2.Items
collection and see ifSelected
property is true or not.