Answered by:
problem in gridview updating

Question
-
Actually i was developing gridview with edit and update and cancel operation.in this i
have one problem that is gridview updating .whenever click gridview updating link button
update successfully message retuned but not working properly means whenever
checking the database what i am updating that will not be change .it contain same
values.updating not worked and also debug the application through break point at the time changestatus after that click update button but txtstatus had not taken .it contain initial value.this is find out by the break points.please help me.how can u acheive this? if any statment wrong please suggest me.
my code:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" AutoGenerateEditButton="True" OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating" OnRowCancelingEdit="GridView1_RowCancelingEdit1" > <Columns> <asp:BoundField DataField="CustomerId" HeaderText="CustomerId" ReadOnly="true" /> <asp:BoundField DataField="CustomerName" HeaderText="CustomerName" ReadOnly="true" /> <asp:BoundField DataField="Designation" HeaderText="Designation" ReadOnly="true" /> <asp:BoundField DataField="Age" HeaderText="Age" ReadOnly="true" /> <asp:BoundField DataField="Gender" HeaderText="Gender" ReadOnly="true"/> <asp:BoundField DataField="EmailId" HeaderText="EmailId" ReadOnly="true" /> <asp:BoundField DataField="Phone" HeaderText="Phone" ReadOnly="true" /> <asp:BoundField DataField="City" HeaderText="City" ReadOnly="true" /> <asp:BoundField DataField="Country" HeaderText="Country" ReadOnly="true" /> <asp:BoundField DataField="Address" HeaderText="Address" ReadOnly="true"/> <asp:BoundField DataField="ZipCode" HeaderText="ZipCode" ReadOnly="true"/> <asp:BoundField DataField="LoanType" HeaderText="LoanType" ReadOnly="true" /> <asp:BoundField DataField="BankName" HeaderText="BankName" ReadOnly="true"/> <asp:BoundField DataField="creditscore" HeaderText="creditscore" ReadOnly="true"/> <asp:BoundField DataField="status" HeaderText="status" ReadOnly="false" /> <asp:BoundField DataField="InterestRate" HeaderText="InterestRate" ReadOnly="true"/> </Columns> </asp:GridView>
my backend gridvewupdating code
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ToString()); GridViewRow row = GridView1.Rows[e.RowIndex]; int cusid =int.Parse(row.Cells[1].Text); TextBox txtstatus = GridView1.Rows[e.RowIndex].Cells[15].Controls[0] as TextBox; string updatequery = ""; updatequery = "update ApplayLoan set status='" + txtstatus.Text + "' where customerid=" + cusid + ""; con.Open(); SqlCommand cmd = new SqlCommand(updatequery, con); int val = cmd.ExecuteNonQuery(); con.Close(); bind(); if (val > 0) { Response.Write("Updated SuccessFully"); } else { Response.Write("Updated not SuccessFully"); } }
my database filedls:
[CustomerId] ,[CustomerName] ,[Designation] ,[Age] ,[Gender] ,[EmailId] ,[Phone] ,[City] ,[Country] ,[Address] ,[ZipCode] ,[LoanType] ,[BankName] ,[creditscore] ,[status] ,[InterestRate]
please help me.
thank u.
- Edited by microsoft web helper installation failed Monday, August 3, 2015 5:25 PM
- Moved by Kristin Xie Tuesday, August 4, 2015 8:13 AM Asp.Net related
Monday, August 3, 2015 5:17 PM
Answers
-
CustomerId is the cell 0.
Try this:
int cusid =int.Parse(row.Cells[0].Text);
Carlos Eduardo Ferreira
- Proposed as answer by Lucio Rogerio SPBanned Wednesday, August 5, 2015 3:15 PM
- Marked as answer by Just Karl Friday, September 4, 2015 9:59 PM
Monday, August 3, 2015 7:06 PM -
Hi,
Based on your code, your case more related to Asp.Net, for questiones related to Asp.Net should be posted in Asp.Net forum. Thanks for your understanding.
Best regards,
kristin
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.Tuesday, August 4, 2015 8:12 AM
All replies
-
CustomerId is the cell 0.
Try this:
int cusid =int.Parse(row.Cells[0].Text);
Carlos Eduardo Ferreira
- Proposed as answer by Lucio Rogerio SPBanned Wednesday, August 5, 2015 3:15 PM
- Marked as answer by Just Karl Friday, September 4, 2015 9:59 PM
Monday, August 3, 2015 7:06 PM -
Hi,
Based on your code, your case more related to Asp.Net, for questiones related to Asp.Net should be posted in Asp.Net forum. Thanks for your understanding.
Best regards,
kristin
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.Tuesday, August 4, 2015 8:12 AM