how can i write a code for deleting a row using gridview

#
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
#
{
#
GridViewRow row = GridView1.Rows[e.RowIndex];
#
 
#
objCust.CustId = Convert.ToInt32(objCust.findCustId().Tables[0].Rows[0][0].ToString());
#
 
#
objCust.DeleteNewUser();
#
 
#
if (objCust.DeleteNewUser() == 1)
#
{
#
bindGvEdit();
#
}
#
}

But I am getting a error as

CS0019: Operator '==' cannot be applied to operands of type 'System.Data.DataSet' and 'int'

Plz suggest how to rectify...

I have written stored procedure for DeleteNewUser in Sql server 2005... I am using visual studio 2005 as well..

Do you guys need any more info regarding this??

The error is in the 18th line.. But I am unable to figure it out my table name is tblCust.. and the bindEvEdit code is:

public void bindGvEdit()
    {
        GridView1.DataSource = objCust.SelectallNewUser();
        GridView1.DataBind();
    }

Your 18 line is if (objCust.DeleteNewUser() == 1), which clearly indicates that DeleteNewUser() is returning the dataset and you are comparing it with 1 that is integer. Please check your function and SP.

@Sufyan 2011 Thx Yep i was wrong.. Actually I was comparing an integer with a dataset...
Actually Guys the problem was with the Bll; Which would look like:

public int DeleteNewUser()
        {
            DBAccess db = new DBAccess();
            db.AddParameter("@iCustId", iCustId);
            return db.ExecuteNonQuery("[tblCust_Delete]",true);
        }

and the modified code would be:

protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
       
        GridViewRow row = GridView1.Rows[e.RowIndex];

        objCust.CustId = Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value);

        if (objCust.DeleteNewUser() > 0)
        {
            bindGvEdit();
        }
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.