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
Vignesh Kumar
NA
1k
415.9k
Add New Item in grid view not working
Oct 28 2013 3:03 AM
Hi,
I am using this below codes to add new items to the grid row and its not getting inserted. I don't know what mistake I done in the code. Can anyone correct me?
code behind(UI):
protected void ResultGridView_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("AddNew"))
{
TextBox EmpID = (TextBox)GridView1.FooterRow.FindControl("txtEmpID");
TextBox Name = (TextBox)GridView1.FooterRow.FindControl("txtName");
TextBox Designation = (TextBox)GridView1.FooterRow.FindControl("txtDesignation");
TextBox City = (TextBox)GridView1.FooterRow.FindControl("txtCity");
AppGridData.InsertGridValues(EmpID.Text, Name.Text, Designation.Text, City.Text);
FillVendorGrid();
}
}
BLL:
public static bool InsertGridValues(string EmpID, string Name, string Description, string City)
{
return AppGridRepository.InsertGridValues(EmpID, Name, Description, City);
}
DAL:
public static bool InsertGridValues(string EmpID, string Name, string Description, string City)
{
string CS = ConfigurationManager.ConnectionStrings[Constants.ConnectionString].ConnectionString;
using (SqlConnection connection = new SqlConnection(CS))
{
SqlCommand command = new SqlCommand();
command.Connection = connection;
command.CommandText = "INSERT INTO [AppInvent_Test]([EmpID],[Name],[Description],[City]) Values('" + EmpID + "','" + Name + "','" + Description + "', '" + City + "')";
connection.Open();
command.ExecuteNonQuery();
}
return true;
}
Reply
Answers (
10
)
Build a Software
ASP.NET MVC - Microsoft Language Translation