Friday, February 12, 2016

Editable Grid View (Part 1)


  • Create a Grid view.

  • Convert some columns to template fields and bind data as follows.

  • Sql query results are like this.

  • Bind the data to grid as follows.

[code] namespace MyWebApp.Presentation { public partial class MyForm : System.Web.UI.Page { MyService myService = new MyService(); protected void Page_Load(object sender, EventArgs e) { try { DataTable dt = myService.getData(); GridView1.DataSource = dt; string[] dataKey = new string[1]; dataKey[0] = "CustListId"; GridView1.DataKeyNames = dataKey; GridView1.DataBind(); } catch (Exception ex) { throw ex; } } } } [/code]

  • You can see the result like this.

Click here to view Part2

No comments:

Post a Comment