Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
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.
Posted
Updated 6-Jun-11 21:37pm
v3
Comments
Dalek Dave 7-Jun-11 3:38am    
Edited for Grammar, Syntax and Readability.
Deepthi Aravind 7-Jun-11 3:40am    
Please post the error .which occured in this code..
pawanvats 7-Jun-11 3:56am    
the error is it is not going in the code block
if (checkslct.Checked)
{
-----------code------------
}
even if i have checked any of checkboxes in my lisview control

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,
 
Share this answer
 
 
Share this answer
 
Comments
Dalek Dave 7-Jun-11 3:38am    
Good Links.
Monjurul Habib 7-Jun-11 3:48am    
thank you.
pawanvats 7-Jun-11 3:46am    
but first is in linq, and second is aplying it on window forms .can't you help me in my code sir

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900