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
srinath
NA
144
0
GridView Rowupdating event
Jun 17 2010 1:36 AM
hi,
I am trying to update the row using gridview_rowupdating event but I am unable to update. I tried the code like this...
foreach (GridViewRow i in GridView1.Rows)
{
TextBox sname = i.FindControl("sname") as TextBox;
TextBox fname = i.FindControl("fname") as TextBox;
TextBox sex = i.FindControl("txtsex") as TextBox;
// Label lblpin1 = i.FindControl("lblpin") as Label;
TextBox tpin = i.FindControl("txtpin") as TextBox;
tpin.Enabled = true;
// lblpin1.Enabled = true;
string pinno;
pinno = Convert.ToString(tpin.Text.Trim());
conn2.Open();
SqlCommand cmd = new SqlCommand("update NRDetails2010 set SNAME='" + sname + "',FNAME='" + fname + "',SEX='" + sex + "' where pin='" + pinno.Trim() + "' and InstCode='" + Session["UId"] + "' and Sem='" + ddlsem.SelectedItem.Text + "' and scheme='" + ddlscheme.SelectedItem.Text.Trim() + "' ", conn2);
cmd.ExecuteNonQuery();
conn2.Close();
}
I am getting error at cmd.ExecuteNonQuery()
Here I am giving connection globally and opening in this event.
In gridview, I am updating 3 fields depending on 4 conditions.
please solve my problem.
Reply
Answers (
1
)
Disable Resizing of new popup windows
Login failed for user 'username'. The user is not associated with a trusted SQL Server connection.