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
Bineesh Viswanath
NA
1k
772.8k
ASP.NET DataGridView Update
Aug 23 2013 2:25 AM
Sir, I want your help in Update function in ASP.NET.
I providing you my code in order.
1)SQL Stored Procedure:-
ALTER PROCEDURE classEdit
@classId numeric(18,0),
@className varchar(20),
@noOfSeats int
AS
if NOT EXISTS (SELECT className FROM tbl_Class WHERE className=@className)
BEGIN
UPDATE tbl_Class
SET
className=@className,
noOfSeats=@noOfSeats
WHERE classId=@classId
END
ELSE if EXISTS (SELECT className FROM tbl_Class WHERE classId=@classId AND className=@className)
BEGIN
UPDATE tbl_Class
SET
noOfSeats=@noOfSeats
WHERE classId=@classId
END
ELSE
BEGIN
return -1
END
2) classInfo.cs:-
public class classInfo
{
public decimal classId
{
get;
set;
}
public string className
{
get;
set;
}
public int noOfSeats
{
get;
set;
}
}
3) ClassSP.cs:-
public void classEdit(classInfo infoClass)
{
try
{
if (sqlCon.State == ConnectionState.Closed)
{
sqlCon.Open();
}
SqlCommand sqlCmd = new SqlCommand("classEdit", sqlCon);
sqlCmd.CommandType = CommandType.StoredProcedure;
sqlCmd.Parameters.Add("@classId", SqlDbType.Decimal).Value = infoClass.classId;
sqlCmd.Parameters.Add("@className", SqlDbType.NVarChar).Value = infoClass.className;
sqlCmd.Parameters.Add("@noOfseats", SqlDbType.Int).Value = infoClass.noOfSeats;
int incount = sqlCmd.ExecuteNonQuery();
if (incount > 0)
{
HttpContext.Current.Response.Write("<script>alert('Updated Successfully');</script>");
}
}
catch (Exception )
{
throw;
}
finally
{
sqlCon.Close();
}
}
I want your help from here.
I sets btnSave.Text="Update" when press edit link button in gridview
please send me the btn_Click function to update
Reply
Answers (
2
)
Data Insertion Error in ASP.NET
view