Click here to Skip to main content
13,449,546 members (36,180 online)
Rate this:
Please Sign up or sign in to vote.
This question can be ask here many time but my case is different. Please forgive me if i am wrong i have a page in which i have text-box and a button when i enter department name in text-box and press submit button my data store in the database

Now what i want is i want
(1) When i press submit button i can see that department in my grid-view.
(2) to show my department name in grid with edit and delete link so that when i click on edit link department name will pop in the department text-box and submit button become update button and when i make some changes and click on update button it will update and show it in the grid.

how can i do that This is my department page.cs code:
public partial class DepartmentMaster : System.Web.UI.Page
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["WebGallery"].ToString());
SqlDataAdapter da; DataTable dt = new DataTable();
 DataSet ds = new DataSet();
protected void Page_Load(object sender, EventArgs e)
{ if (!IsPostBack)
da = new SqlDataAdapter("Select * from Department_Master", con); da.Fill(ds);
gvDepartment.DataSource = ds;
 protected void btnSubmit_Click(object sender, EventArgs e)
 { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyGallery"].ToString()))
con.Open(); string DepartmentName = tbDepartment.Text.Trim();
 using (SqlCommand cmd = con.CreateCommand())
cmd.CommandText = "insert into Department_Master(DepartmentName) values('" + DepartmentName + "')";
cmd.Parameters.AddWithValue("@DepartmentName", tbDepartment.Text.Trim());
tbDepartment.Text = "";
Posted 29-Jun-13 2:59am

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.180318.3 | Last Updated 29 Jun 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100