Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,


I like to give provisional for users in grid view to delete ,edit and update others only view records.
my code

if (Convert.ToString(Session["name"]) == "ACCOUNTANT")
{

con.Open();
SqlCommand cmd = new SqlCommand("sp_trainingdistwise", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@distid", Convert.ToInt32(distid));
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
gvtraining.DataSource = ds;
gvtraining.DataBind();

gvtraining.Columns[0].Visible = false;
con.Close();
}

I am getting error

SQL
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Posted
Comments
ZurdoDev 12-Mar-14 7:24am    
Debug your code and find out which line is causing the error and why.
abdussalam143 14-Mar-14 8:27am    
i think dataset is empty or try it like
gvtraining.DataSource = ds[0];

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