在C#asp.net中处理列表视图中的复选框 [英] handling checkboxes in listview in c# asp.net
本文介绍了在C#asp.net中处理列表视图中的复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我正在使用带列表视图的复选框.
我在listview控件的所有行上都选中了一个复选框.
在提交时,我想获取所有选中了复选框的行.
这是我的代码.
Hi guys,
I am working on checkboxes with listview.
I have given a checkbox on all rows of my listview control.
On submit I want to get all those rows whose checkboxes are selected.
This is my code.
protected void btnsavetofolders_Click(object sender, EventArgs e)
{
foreach (ListViewDataItem item in LstViewAppbyjob.Items)
{
CheckBox checkslct = item.FindControl("checkslct") as CheckBox;
if (checkslct != null)
{
if (checkslct.Checked)
{
Label lblprofileid = item.FindControl("lblprofileid") as Label;
if (Session["EmployerId"] != null)
{
JPosted.EmployerId = Convert.ToInt16(Session["EmployerId"]);
JPosted.intProfileId = Convert.ToInt16(lblprofileid.Text);
JPosted.JobPostedId = Convert.ToInt16(Request.QueryString["JobPostedId"]);
if (DdlFolders.SelectedIndex == 0)
{
JPosted.intFolderId = 0;
}
else
{
//JS.intFolderId = Convert.ToInt16(DSShowEmpFolders.Tables[0].Rows[0]["FolderId"]);
JPosted.intFolderId = Convert.ToInt32(DdlFolders.SelectedValue);
}
int CountSave;
CountSave = JPosted.InsertIntoSavedProfileInEmpFolders();
if (CountSave > 1)
{
lblmsg.Text = "This profile Already exist in your folder";
}
else
lblmsg.Text = "This profile has been successfully saved to your folder";
}
}
}
我选中了一个复选框,但没有得到它.
请帮帮我
在此先感谢
已代码块.
I checked a checkbox and it is not getting it.
help me please
Thanks in advance
Edited : code block.
推荐答案
感谢大家.问题已解决.
实际上我在绑定listview之前没有检查页面回发.
谢谢大家的支持,
thank u all guys. problem has been resolved.
actually i was not checking page postback before binding the listview.
thank you all guys for your kind support,
^ ]
http://msdn.microsoft.com/en-us/library/system.windows.forms.listview.checkeditems.aspx [ ^ ]
http://blogs.msdn.com/b/davidklinems/archive/2007/06/18/quick-tip-getting-the-collection-of-checked-listview-items.aspx[^]
http://msdn.microsoft.com/en-us/library/system.windows.forms.listview.checkeditems.aspx[^]
这篇关于在C#asp.net中处理列表视图中的复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文