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
Nitin Sharma
NA
154
62.5k
row update button coding in grid view for asp.net c#
Mar 26 2014 2:00 AM
i have use this part of code for update a row in gridview in c# asp.net
in my past project it was worked but now it is not working can anybody help me in this i have pase my sql query, asp gridview code and my logical code too
please advise me how to update a row in gridview
SQL Query
create database test
use test
create table gridview(id int identity(1,1),ename varchar(50),city varchar(50))
insert into gridview values('nitin','hisar')
insert into gridview values('deepak','gwalior')
insert into gridview values('raman','delhi')
select*from gridview
update gridview set ename='nitin sharma', city='haryana' where id=1
default.aspx
<asp:GridView ID="GridView1" runat="server" Height="189px" Width="332px"
AutoGenerateDeleteButton="True" AutoGenerateEditButton="True" DataKeyNames="id"
onrowcancelingedit="GridView1_RowCancelingEdit"
onrowdeleting="GridView1_RowDeleting" onrowediting="GridView1_RowEditing"
onrowupdating="GridView1_RowUpdating">
</asp:GridView>
default.aspx.cs
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value);
string name=GridView1.Rows[e.RowIndex].Cells[0].Text;
string city=GridView1.Rows[e.RowIndex].Cells[1].Text;
if (con.State == ConnectionState.Closed)
{
con.Open();
}
SqlCommand cmd = new SqlCommand("update gridview set ename='"+name+"', city='"+city+"' where id='"+id+"'", con);
cmd.ExecuteNonQuery();
con.Close();
GridView1.DataBind();
display();
}
please help me
Reply
Answers (
8
)
Interface in .Net
Issue regarding connectivity ASP.net with oracle...