0

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..

2
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by geniusvishal
0

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();
    }
0

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.

0

@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();
        }
    }
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.