Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
hi guys, i am working on the deletion of users profile and updation of his status(active or deative). i have done all this in gridview, bt now because of change in functionality i have to do this in listview .
this is my code

protected void GrdJsAllProfileDetail_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        try
        {
            DataRowView dRowView = (DataRowView)e.Row.DataItem;
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                                ImageButton imgactivedeactive = (ImageButton)e.Row.FindControl("imgactivedeactive");
                imgactivedeactive.CommandName = dRowView["ProfileId"].ToString();
                if (dRowView["JSStatus"].ToString() == "True")
                {
                                          imgactivedeactive.ImageUrl = "..\\Images\\active.png";
                    imgactivedeactive.CommandArgument = "False";
                }
                else
                {
                    imgactivedeactive.ImageUrl = "..\\Images\\deactive.png";
                    imgactivedeactive.CommandArgument = "True";
                }
            }
        }
        catch (Exception ex)
        {
        }
    }


C#
protected void GrdJsAllProfileDetail_RowCommand(object sender, GridViewCommandEventArgs e)
{
    try
    {
        jsRegister.IntJobseekerid = Convert.ToInt32(Session["JobSeekerId"]);
        jsRegister.ProfileId = Convert.ToInt32(e.CommandName);
        jsRegister.ISPROFILESTATUS = Convert.ToBoolean(e.CommandArgument);
        jsRegister.Update_JobSeeker_Profile_Status();
        DisplayAllJobSeekerProfile();

    }
    catch (Exception ex)
    {
    }
}

        protected void GrdJsAllProfileDetail_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {

            // SQL Delete Command
            
            GridViewRow row = (GridViewRow)GrdJsAllProfileDetail.Rows[e.RowIndex];
            ImageButton lndlt = (ImageButton)row.FindControl("imgactivedeactive");
            if (lndlt.ImageUrl == "..\\Images\\deactive.png")
            {
                Label lbldeleteID = (Label)row.FindControl("lblProfileId");

                jsRegister.ProfileId = Convert.ToInt32(lbldeleteID.Text);
                jsRegister.Delete_JSApplyJob();
                jsRegister.Delete_JSProfile();
                DisplayAllJobSeekerProfile();

            }
            else
            {


                string strjscript = "alert('Sorry, You can't Delete An Active Profile');";
ScriptManager.RegisterStartupScript(this, this.GetType(), "RedirectScript", strjscript, true);
return;

}
        } 

can you please tell me which events of listview works same like grid views event used in this code .

thanks a lot in advance guys
Posted
Updated 25-Jun-11 5:37am
v2

1 solution

Both has common properties, events also the data operation, sorting, etc., So you can convert the code easily, just spend the time yourself.

Look at the GridView Class[^] & ListView Class[^] at MSDN
Gridview Vs ListView[^]
Comparing ListView with GridView,DataList and Repeater [^]
 
Share this answer
 
Comments
Espen Harlinn 25-Jun-11 12:29pm    
Fair reply, my 5

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