Here is my code snipet which i didnt get updated. [Resolved]

Posted by Joewilliam under Regular Expressions on 6/21/2011 | Points: 10 | Views : 1255 | Status : [Member] | Replies : 5
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{

GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex];
TextBox bid = (TextBox)row.Cells[7].FindControl("txtbid");
TextBox bookname = (TextBox)row.Cells[0].FindControl("txtbname");
TextBox author = (TextBox)row.Cells[1].FindControl("txtau");
TextBox category = (TextBox)row.Cells[2].FindControl("txtcate");
TextBox publisher = (TextBox)row.Cells[3].FindControl("txtpub");
TextBox quantity = (TextBox)row.Cells[4].FindControl("txtquan");

string qry1 = "Update tbl_addbook SET Book_name='" + bookname.Text + "',Author='" + author.Text + "',Category='" + author.Text + "',Publisher='" + publisher.Text + "',Quantity='" + quantity.Text + "' where bid='"+ bid.Text +"' ";
var cmd = Cmd(qry1);
cmd.ExecuteNonQuery();
bind();
}


William Mary


Responses

Posted by: Joewilliam on: 6/21/2011 [Member] Starter | Points: 50

Up
0
Down

Resolved
I got the answer.

Here is my code which run successfully.

protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)

{
GridView1.EditIndex = -1;
bind();
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex];
Label lbl = (Label)row.FindControl("ID");
string qry = "delete from tbl_addbook where bid='" + lbl.Text + "'";
var cmd = Cmd(qry);
cmd.ExecuteNonQuery();
bind();
}


protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex];
TextBox bid = (TextBox)row.FindControl("txtbid");
TextBox bookname = (TextBox)row.FindControl("txtbname");
TextBox author = (TextBox)row.FindControl("txtau");
TextBox category = (TextBox)row.FindControl("txtcate");
TextBox publisher = (TextBox)row.FindControl("txtpub");
TextBox quantity = (TextBox)row.FindControl("txtquan");

string qry1 = "Update tbl_addbook SET Book_name='"+ bookname.Text +"',Author='"+ author.Text +"',Category='"+ category.Text +"',Publisher='"+ publisher.Text +"',Quantity='"+ quantity.Text +"' where bid='" + bid.Text + "'";

var cmd = Cmd(qry1);
cmd.ExecuteNonQuery();
bind();
}

protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
bind();
}


William Mary

Joewilliam, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: A4u6178 on: 6/21/2011 [Member] Starter | Points: 25

Up
0
Down
Hi Joe,
Put ur code inside the code tag when posting..

Thanks & Regards;
aaa

Joewilliam, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lakn2 on: 6/21/2011 [Member] Starter | Points: 25

Up
0
Down
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)

{

GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex];
TextBox bid = (TextBox)row.Cells[7].FindControl("txtbid");
TextBox bookname = (TextBox)row.Cells[0].FindControl("txtbname");
TextBox author = (TextBox)row.Cells[1].FindControl("txtau");
TextBox category = (TextBox)row.Cells[2].FindControl("txtcate");
TextBox publisher = (TextBox)row.Cells[3].FindControl("txtpub");
TextBox quantity = (TextBox)row.Cells[4].FindControl("txtquan");

string qry1 = "Update tbl_addbook SET Book_name='" + bookname.Text + "',Author='" + author.Text + "',Category='" + author.Text + "',Publisher='" + publisher.Text + "',Quantity='" + quantity.Text + "' where bid='"+ bid.Text +"' ";
var cmd = Cmd(qry1);
cmd.ExecuteNonQuery();
gridview1.Editindex=-1;
bind();
}


Thanks&Regards
LakshmiNarayana Nalluri.

Joewilliam, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naimishforu on: 6/21/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
great that you have resolved it. enjoy!!

Thanks,
Naimish
http://dotnetinterview.zxq.net/
http://naimishpandya.blogspot.in/

Joewilliam, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Joewilliam on: 6/22/2011 [Member] Starter | Points: 25

Up
0
Down
Thank u

William Mary

Joewilliam, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response