TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
srikanth nalluri
NA
10
0
how to delete a row in grid view by setting auto genarate delete button is true
May 26 2010 11:07 AM
hi
i am trying to delete a row in grid view by using c# language.
but it is displaying an error like
"Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index"
can
any one please
suggest me where i did mistake.
i am sending the total code
public partial class _Default : System.Web.UI.Page
{
SqlConnection con = new SqlConnection("server=.;user id=sa;password=sri;database=nalluri");
protected void Page_Load(object sender, EventArgs e)
{
SqlDataAdapter da = new SqlDataAdapter("select* from emp", con);
DataSet ds = new DataSet();
da.Fill(ds, "empdetails");
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
SqlCommand cmd = new SqlCommand("delete emp where eno='" + GridView1.DataKeys[e.RowIndex].Values[0].ToString() + "'",con);
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
}
}
Reply
Answers (
2
)
Fix the Size of DataList
calling a web service method in WCF layer