Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
hey

i try to approve documents using following code and quey


CODE

C#
protected void GrdFileApprove_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "_Approve")
            {
                using (SqlConnection con = DataAccess.GetConnected())
                {
                    try
                    {
                        int rowindex = Convert.ToInt32(e.CommandArgument);
                        GridViewRow row = (GridViewRow)((Control)e.CommandSource).NamingContainer;
                        LinkButton Prove_Button = (LinkButton)row.FindControl("BtnApprove");
                        SqlCommand cmd = new SqlCommand("approvefiles", con);
                        cmd.CommandType = CommandType.StoredProcedure;
                        int result = cmd.ExecuteNonQuery();
                        if (result != 0)
                        {
                            GrdFileApprove.bind();
                        }
                    }

                    catch (Exception ex)
                    {
                    }
                    finally
                    {
                        con.Close();
                    }
                }
            }


            else if (e.CommandName == "_Reject")
            {
               
            }

            }



then when i debug following error appear

The name 'DataAccess' does not exist in the current context

'System.Web.UI.WebControls.GridView' does not contain a definition for 'bind' and no extension method 'bind' accepting a first argument of type 'System.Web.UI.WebControls.GridView' could be found (are you missing a using directive or an assembly reference?)
Posted
Updated 26-Sep-13 1:58am
v3
Comments
Harshil_Raval 26-Sep-13 8:05am    
hi, there is no method like gridview.bind()!!! To bind grid you must have one datasource, and then you can bind grid.

gridview.DataSource = your datasource;
gridview.DataBind();
Diya Ayesa 26-Sep-13 8:43am    
and what about the first error
Harshil_Raval 26-Sep-13 8:56am    
At which line you are facing this error? The name 'DataAccess' does not exist in the current context
Diya Ayesa 26-Sep-13 9:19am    
using (SqlConnection con = DataAccess.GetConnected())


IN THIS LINE
Harshil_Raval 26-Sep-13 9:28am    
So, DataAccess is your static class name, in which you have created, static function GetConnected. From this you are getting connection string. Right?

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