AspdotnetCodes.com
Search
Articles
Books
Resources
Asp.Net News
Downloads
Free Tech Magazines
Asp.Net Web Hosting
Archives
Softwares
Newsletter
Suggest Us
Link to Us
Feeds Subscription
Articles
Questions & Answers
Tips & Tricks
 Simple Insert, Select, Edit, Update and Delete in Asp.Net GridView control
Posted by Moderator1 on 7/12/2007 11:24:12 AM Category: ADO.NET
Total Views : 334040
Add to my favorites
Email to friend
  
Introduction
This article explains the methods of binding Asp.Net GridView control with simple DataSet or DataTable, and also explains the methods like Insert, Edit, Update and Delete function in the GridView control.
You can see most of the articles and tutorials in many websites teach you the way to bind a GridView control to the database with some Data Source controls such as SQLDataSource, ObjectDataSource, AccessDataSource and even XMLDatasource. But this article focus on the other way, by binding the GridView control to the database with the help of simple DataTable and perform adding of new records to the database from the footer row of the GridView control. And on each row, we are going to manipulate the records by editing, updating, cancelling and deleting functions.

Sample Scenario 

For demonstration, we are going to fill an ASP.NET GridView control with data from a database. Let us take a simple Customer Table. This customer table contains 6 columns such as Customer Unique Code, Name of 
the Customer, Gender, City, State and Customer Type. We are going to add new records to the database and populate it in the GridView control. Then record manipulation (edit, update and delete) will be done in each and every column with the server controls such as TextBox and DropDownList. In these 6 columns, we are not going to display Customer Code, and to edit Customer Name and City columns we are going to provide TextBox, to edit Gender and Customer Type we are going to use DropDownList. Additionally, the values for Gender DropDownList will be filled with static values such as Male and Female, other DropDownList for Customer Type, we will be filled dynamically with the values from the Database.

Pre-requisites

Your project or website must be ASP.NET AJAX enabled website. Because we are going to add the GridView in an UpdatePanel. So your GridView control will be look smart without unnecessary postbacks. You need to create a Customer Table with 6 columns for Customer Code[Code], Name[Name], Gender[Gender], City[City], State[State] and Customer Type[Type], with your desired data types. Then create a class file in your App_Code folder and create a Default.aspx along with code-behind file Default.aspx.cs.

Step 1. Create Class File ‘CustomersCls.cs’

We need to create a class file to do database manipulations such as select, insert, delete and update data in the Customer Table. So we add a class file as ‘CustomersCls.cs’ in App_Code section. Let us write five methods in the class file as follows
public void Insert(string CustomerName, string Gender, string City, string State, string CustomerType)
{
    // Write your own Insert statement blocks
}

public DataTable Fetch()

  // Write your own Fetch statement blocks, this method should return a DataTable
}

public DataTable FetchCustomerType()
{
  // Write your own Fetch statement blocks to fetch Customer Type from its master table and this method should return a DataTable
}

public void Update(int CustomerCode, string CustomerName, string Gender, string City,  string CustomerType)
{
  // Write your own Update statement blocks.
}

public void Delete(int CustomerCode)
{
  // Write your own Delete statement blocks.
}
Step 2: Make Design File ‘Default.aspx’

In the Default.aspx page, add an UpdatePanel control. Inside the UpdatePanel, add a GridView, set AutoGenerateColumns as False. Change the ShowFooter Flag to True and set the DataKeyNames your column name for Customer Code and Customer Type, in our case it is Code and Type. Then click on the Smart Navigation Tag of the GridView control, choose Add New Column and add 5 BoundField columns with DataField values as Name, Gender, City, State and Type, plus 2 CommandField columns with one for Edit/Update and another for Delete functions. Now your GridView control is ready. But as first step, we need to add some new records into the database. For that we need to place the controls in the Footer row. So we have to convert all these BoundField columns as TemplateField columns. To do this again, click on the Smart Navigation Tag on the GridView choose Edit Columns, the Field’s property window will open. Select column by column from Name to Customer Type, include also Edit column, and select ‘Convert this field into a TemplateField’. Now all the BoundField columns will be converted to TemplateField columns except the Delete column.

Column[0] – Name

Right click on the GridView control, select Edit Template, choose column[0] – Name, you can view a label placed in the ItemTemplate section and a TextBox placed in the EditItemTemplate section. Add another Texbox in the FooterTemplate section and name it as txtNewName.

Column[1] - Gender

Now again select Edit Template, choose column[1] - Gender, replace the TextBox with a DropDownList, name it as cmbGender, add Male and Female as their ListItem values. On the Edit DataBindings of the cmbGender, add Eval("Gender") to its selectedvalue. Add another DropDownList in the FooterTemplate section and name it as cmbNewGender.

Column[2] –City & Column[3] - State

Add Texboxes in both column’s FooterTemplate section and name it as txtNewCity and txtNewState respectively.
Column[4] - Type

In this column’s EditItemTemplate section, replace the TextBox with a DropDownList, name it as cmbType. Also add another DropDownList in the FooterTemplate section and name it as cmbNewType. Both these DropDownList’s we are going to fill with dynamic data from database. So specify both DropDownList’s DataTextField and DataValueField as Type.

Column[5] - Edit

Just add a link button into the FooterTemplate section, specify its CommandName property as ‘AddNew’.

For your persual, we have provided the complete source code of the GridView control below. The State column in our sample is read-only. So you cannot find TextBox for that column in the EditItemTemplate section.

Click here to view Source Code of the GridView Control HyperLink
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="Code, Type" OnRowCancelingEdit="GridView1_RowCancelingEdit" OnRowDataBound="GridView1_RowDataBound" OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating" OnRowCommand="GridView1_RowCommand" ShowFooter="True" OnRowDeleting="GridView1_RowDeleting">
<Columns>

<asp:TemplateField HeaderText="Name" SortExpression="Name"> <EditItemTemplate>
  <asp:TextBox ID="txtName" runat="server" Text='<%# Eval("Name") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
  <asp:TextBox ID="txtNewName" runat="server"></asp:TextBox> </FooterTemplate>
<ItemTemplate>
  <asp:Label ID="Label2" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Gender">
<EditItemTemplate>
  <asp:DropDownList ID="cmbGender" runat="server" SelectedValue='<%# Eval("Gender") %>'>
    <asp:ListItem Value="Male" Text="Male"></asp:ListItem>
    <asp:ListItem Value="Female" Text="Female"></asp:ListItem>
  </asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
  <asp:Label ID="Label2" runat="server" Text='<%# Eval("Gender") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
  <asp:DropDownList ID="cmbNewGender" runat="server" >
    <asp:ListItem Selected="True" Text="Male" Value="Male"></asp:ListItem>
    <asp:ListItem Text="Female" Value="Female"></asp:ListItem> </asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="City">
<EditItemTemplate>
  <asp:TextBox ID="txtCity" runat="server" Text='<%# Bind("City") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
  <asp:TextBox ID="txtNewCity" runat="server" ></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
  <asp:Label ID="Label3" runat="server" Text='<%# Bind("City") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="State" SortExpression="State">
<EditItemTemplate>
  <asp:Label ID="Label1" runat="server" Text='<%# Eval("State") %>'></asp:Label>
</EditItemTemplate>
<FooterTemplate>
  <asp:TextBox ID="txtNewState" runat="server" ></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
  <asp:Label ID="Label4" runat="server" Text='<%# Bind("State") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Type">
<EditItemTemplate>
  <asp:DropDownList ID="cmbType" runat="server" DataTextField="Type" DataValueField="Type"> </asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
  <asp:Label ID="Label5" runat="server" Text='<%# Eval("Type") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
  <asp:DropDownList ID="cmbNewType" runat="server" DataTextField="Type" DataValueField="Type"> </asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Edit" ShowHeader="False">
<EditItemTemplate>
  <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update" Text="Update"></asp:LinkButton>
  <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"></asp:LinkButton>
</EditItemTemplate>
<FooterTemplate>
  <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="AddNew" Text="Add New"></asp:LinkButton>
</FooterTemplate>
<ItemTemplate>
  <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField HeaderText="Delete" ShowDeleteButton="True" ShowHeader="True" />

</Columns>
</asp:GridView>


Step 3: Make Code-behind File ‘Default.aspx.cs’

Now we are going to do the code-behind part of this page. Les us explain you event by event coding on each methods. In the code-behind page, create an instance for the Customer class as follows

CustomersCls customer=new CustomersCls();

Then create a private method 'FillCustomerInGrid' to retrieve the existing customer list from the database and bind it to the GridView. The CustomersCls class’s Fetch() method is used and it returns the data to a DataTable. On first stage it will return empty rows. So you cannot see any header, data or even footer rows of the GridView control. You can only see an empty space or you see only the EmptyDataText. So you cannot add any new data from the footer row.

private void FillCustomerInGrid()

   DataTable dtCustomer= customer.Fetch(); 

 if (dtCustomer.Rows.Count>0) 
 {
    GridView1.DataSource = dtCustomer; 
    GridView1.DataBind(); 
 }
 else
 { 
      dtCustomer.Rows.Add(dtCustomer.NewRow()); 
      GridView1.DataSource = dtCustomer; 
      GridView1.DataBind(); 

      int TotalColumns = GridView1.Rows[0].Cells.Count; 
      GridView1.Rows[0].Cells.Clear(); 
      GridView1.Rows[0].Cells.Add(new TableCell()); 
      GridView1.Rows[0].Cells[0].ColumnSpan = TotalColumns; 
      GridView1.Rows[0].Cells[0].Text = "No Record Found"; 
  }
}

In this article, we have provided a workaround to fix this problem. Closely look at the method FillCustomerInGrid, there is a conditional statement to check the rows exists in DataTable or not. Now go to the else part of the if statement, see the block of code we provided there. Simply we have added an empty row to the DataTable. Then bind it to the GridView control. To give a professional look to the GridView control, we do little bit more by providing ColumnSpan and set a Text as "No Record Found", this text will be displayed if the GridView is empty without any rows and you can see both the Header and Footer of the GridView control.

Initialize GridView control

In the page load event, we have to call this FillCustomerInGrid method as follows,

protected void Page_Load(object sender, EventArgs e)
{
  If (!IsPostBack)
  {
     FillCustomerInGrid();
   }
}

Fill DropDownList in GridView with dynamic values

In column[4] - Type, there are two DropDownList controls, one in the EditItemTemplate section (cmbType) and another in FooterTemplate (cmbNewType). We have to fill both these DropDownList controls with some dynamic data. If you look at our CustomersCls class, we have a separate method called FetchCustomerType. In the RowDataBound event of the GridView control insert the following code.

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
  if (e.Row.RowType == DataControlRowType.DataRow)
  {
   DropDownList cmbType = (DropDownList)e.Row.FindControl("cmbType");

  if (cmbType != null)
  {
    cmbType.DataSource = customer.FetchCustomerType();
    cmbType.DataBind(); 
    cmbType.SelectedValue = GridView1.DataKeys[e.Row.RowIndex].Values[1].ToString();
   }
 }

if (e.Row.RowType == DataControlRowType.Footer)
{
    DropDownList cmbNewType = (DropDownList)e.Row.FindControl("cmbNewType");
    cmbNewType.DataSource = customer.FetchCustomerType();
    cmbNewType.DataBind();
 }

}


Previously in this article, we have set the DataKeyNames values as Code, Type. If you see in the above code, we use one of the DataKeyNames value as the SelectedValue for the cmbType control, this is to retain the value of the cmbType in EditMode. The index value of Code is 0 and Type is 1. So we use as follows

cmbType.SelectedValue = GridView1.DataKeys[e.Row.RowIndex].Values[1].ToString();

So far we have initialized the GridView control with the datatable and also make some values to be filled in the Footer DropDownList cmbNewType. Run the application, you can see the GridView only with the Footer row and data in the cmbNewType control. Let us start to code for adding new records into the database when we click ‘Add New’ linkbutton.

Add New Records from GridView control

Create an event for the GridView’s RowCommand and add the following code in it.

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
  if (e.CommandName.Equals("AddNew"))
  {
   TextBox txtNewName=(TextBox)GridView1.FooterRow.FindControl("txtNewName"); 
   DropDownList cmbNewGender = (DropDownList)GridView1.FooterRow.FindControl("cmbNewGender"); 
   TextBox txtNewCity = (TextBox)GridView1.FooterRow.FindControl("txtNewCity"); 
   TextBox txtNewState = (TextBox)GridView1.FooterRow.FindControl("txtNewState"); 
   DropDownList cmbNewType = (DropDownList)GridView1.FooterRow.FindControl("cmbNewType");

   customer.Insert(txtNewName.Text, cmbNewGender.SelectedValue, txtNewCity.Text, txtNewState.Text, cmbNewType.SelectedValue) ; 
      FillCustomerInGrid();
  }
}

In the above code, we are declaring and finding the controls in the GridView’s footer section and use the CustomersCls class insert method to add the new data into the database. Then we are calling the FillCustomerInGrid method to fill the GridView control with the newly inserted values. Now save everything and run your application. Put some test data in the Textboxes and select some values in the DropDownLists and click on the Add New linkbutton. You can see data inserted into the database and listed in the GridView control.
Edit and Update in GridView

In the RowEditing event of the GridView, add the following lines of code. This will switch a specific row of the GridView to Edit Mode.

 
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
  GridView1.EditIndex = e.NewEditIndex;
  FillCustomerInGrid();
}

After the GridView swithes to Edit Mode, you can view the TextBoxes and DropDownlList controls along with Update and Cancel linkbuttons in the Edit mode. To cancel this action, add the following two lines of code in the GridView’s RowCancelingEdit event.

protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
  GridView1.EditIndex = -1;
   FillCustomerInGrid();
}
You can update the data to the customer table, by adding the following lines of code in the GridView’s RowUpdating event.

protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
  TextBox txtName = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtName");
  DropDownList cmbGender = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("cmbGender");
  TextBox txtCity = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtCity");
  DropDownList cmbType = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("cmbType");

 customer.Update(GridView1.DataKeys[e.RowIndex].Values[0].ToString(),txtName.Text, cmbGender.SelectedValue,txtCity.Text, cmbType.SelectedValue);
  GridView1.EditIndex = -1;
  FillCustomerInGrid();
}

The above block of codes in RowUpdating event, finds the control in the GridView, takes those values in pass it to the CustomersCls class Update method. The first parameter GridView1.DataKeys[e.RowIndex].Values[0].ToString() will return the Code of the Customer. That is the unique code for each customer to perform update function.

Delete in GridView

To delete a row from the customer table, add the following lines of code in the GridView’s RowDeleting event. Here you have to pass the unique Code of customer which is in GridView1.DataKeys[e.RowIndex].Values[0].ToString() to the Delete method of the CustomersCls class.

protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
  customer.Delete(GridView1.DataKeys[e.RowIndex].Values[0].ToString());
  FillCustomerInGrid();
}


This article gives you some basic idea of inserting data into database from a GridView control and does all database manipulations within the GridView without binding it with any Asp.Net Data source controls.
Click here to view our Sample GridView with database manipulations
You need to Login or Register to download Source Code.
 
Viewer's Comments
Posted by Ramamohan on 7/20/2007 5:54:26 AM
Very nice Article...
 
Posted by Frederico on 7/20/2007 5:54:58 AM
I apologise before hand for what I´m about to ask but can you or do you know of an example like this one but in VB.
 
Posted by mani on 7/23/2007 5:49:14 AM
this is very useful to me..can u send to me sample project code? thanks mani
 
Posted by Eddie De Guzman on 7/23/2007 12:59:59 PM
Excellent. can you please send to me the complete source code / project file? Thanks. Eddie
 
Posted by Subramanian on 7/24/2007 4:25:02 AM
Hi, This Article is Very Useful to me. Lot of Thanks To U Thanks, Mani
 
Posted by Vikas on 7/24/2007 10:34:03 PM
Good one. can you please send to me the complete source code / project file? Thanks. Vikas
 
Posted by priya binu on 7/25/2007 1:01:21 AM
very useful article....pls give full source code ...esp class creation part
 
Posted by rasheed on 7/25/2007 1:59:25 AM
very usefullllll
 
Posted by ramesh on 7/26/2007 12:06:17 AM
good article for beginners
 
Posted by kapil on 7/26/2007 4:30:42 AM
I got one dout in ASP.Net how to modify the data and to delete data -
 
Posted by NAWAZ on 7/28/2007 1:54:40 AM
very nice and useful code really appreciateable
 
Posted by Vijay on 8/6/2007 6:34:40 AM
Nice article. Is there any way to give an alert before deleting the record?
 
Posted by nag on 8/7/2007 9:55:24 AM
Thankx for saving my day..
 
Posted by mervin on 8/8/2007 2:17:48 AM
ya very nice i even didnt see like this simple view.. wil u send me a full project for this Regards Mervin
 
Posted by Nj on 8/9/2007 12:09:21 AM
Thanks,this was a grt article,but when i want to put the textboxes in the footer dynamically on the clk of a button "Insert New Row" ,I am able to see the textboxes but when I am trying to access the text in those textboxes using TextBox txtname = (TextBox) GridView1.FooterRow.FindControl("txtName"); rowInsert["Name"] =txtname.Text; its throwing a Nullexception,that means I am not getting anything inside "txtname". Can you suggest me where is the mistake.Thanks
 
Posted by Gopi Saini on 8/9/2007 2:44:36 AM
Excellent work. Can u send the source code of this project. Regards Gopi Saini
 
Posted by Ammar on 8/11/2007 1:05:18 AM
Damn good a thing.. I expect more such articles... Thanks a million baby.. you saved a lot of my time.
 
Posted by HARIS on 8/11/2007 5:57:38 AM
RESPECTED............................ I WANT TO BIND GRIDVIEW WITH IMAGE , I ALREADY STORDE IMAGE IN DATA BASE (SQL) IN BINARY FORMATE.HOW CAN I RETIVE THAT IMAGE IN GRIDVIEW ACCOURDING TO THERE RELIVENT DATA. I USE ASP.NET (C#) .......................................
 
Posted by ishak on 8/11/2007 9:24:27 AM
hey i tried this with my page that i have began as normal asp.net page but then when i see this article i added the AJAX extensions but when i tried to build it, it gaves manyn errors with web.config file.. can you please send the project code? so that i can see where my mistake is.. thank you.
 
Posted by ishak on 8/11/2007 9:26:49 AM
and finally i want my datatable and gridview not to directly manipulate the database ... but onlyn when i press a UPDATE DATABASE button.. untill there all edited and inseretd and deleted row changes should be kept in datatable and everychange in datatable should be seen in gridview.. ? how can i achieve this?
 
Posted by Herman Dolder on 8/14/2007 4:35:06 PM
Excellent. can you please send to me the complete source code / project file? Thanks. Herman
 
Posted by preet on 8/14/2007 11:59:11 PM
hey its nice.. but what i want to know is that any way to put validations in edit mode. actualy i tried ur sample and it allows me add null names and cities is there any way to stop it and put validations in edit mode.
 
Posted by Richard on 8/15/2007 2:14:37 AM
Very useful article. But I am a beginner of ASP.NET. I can not even find the UpdatePanel control. Is it possible to email me the whole project? My email is xiao_john@yahoo.com Thank you very much!
 
Posted by durga on 8/20/2007 11:31:20 PM
excellent one ...good job Its different example than others ..
 
Posted by sahdev on 8/21/2007 12:27:24 AM
Excellent. can you please send to me the complete source code / project file? Thanks.
 
Posted by ph0o on 8/21/2007 6:10:42 AM
excellent work!!! thanks a lot!!
 
Posted by Gopianand S. on 8/27/2007 6:36:21 AM
one of the good article which i have seen. thank you very much!!
 
Posted by Nandu on 8/29/2007 5:07:52 AM
This is GOod
 
Posted by kanchan on 8/30/2007 1:20:32 AM
too good
 
Posted by jha-jha on 9/6/2007 3:27:40 AM
Nice one. can you please send me the complete source code? Heap thanks! :-)
 
Posted by siri on 9/11/2007 4:44:24 AM
Good one. can you please send to me the complete source code / project file? Thanks. Vikas
 
Posted by siri on 9/11/2007 4:44:57 AM
Good one. can you please send to me the complete source code / project file? Thanks.
 
Posted by Pietkeiy on 9/11/2007 10:08:26 PM
I have reading ur coding & apply it for small project,some error that responding.Would give me this code project.Thanks
 
Posted by Thurman Felder on 9/17/2007 11:07:19 AM
Great article. I was wondering if you could send me the source code.
 
Posted by Thurman Felder on 9/17/2007 11:08:37 AM
Great article. I was wondering if you could send me the source code. Thanks
 
Posted by piyush on 9/20/2007 6:03:40 AM
very good ... edit code dose not support in.net2003
 
Posted by Excellent on 9/20/2007 9:24:35 AM
Hiii...ur article will lot help for me with Edit,Cancle,Delete,Select...But i can't able to understand the Update method....so..can u tell me how to narrate to my application that Update...i trid to explain my application here...... i am implementing gridview in 3tire arch,i mean... 1)BO layar(in that i wrote all the properties to table columns) 2)DAO layar(in that i was implemented database connections,calling storedprocedures...ect through calling the BO layar 3)FACAD(in that i just creat
 
Posted by Excellent on 9/20/2007 9:24:46 AM
Hiii...ur article will lot help for me with Edit,Cancle,Delete,Select...But i can't able to understand the Update method....so..can u tell me how to narrate to my application that Update...i trid to explain my application here...... i am implementing gridview in 3tire arch,i mean... 1)BO layar(in that i wrote all the properties to table columns) 2)DAO layar(in that i was implemented database connections,calling storedprocedures...ect through calling the BO layar 3)FACAD(in that i just creat
 
Posted by Excellent on 9/20/2007 9:24:56 AM
Hiii...ur article will lot help for me with Edit,Cancle,Delete,Select...But i can't able to understand the Update method....so..can u tell me how to narrate to my application that Update...i trid to explain my application here...... i am implementing gridview in 3tire arch,i mean... 1)BO layar(in that i wrote all the properties to table columns) 2)DAO layar(in that i was implemented database connections,calling storedprocedures...ect through calling the BO layar 3)FACAD(in that i just creat
 
Posted by Pruthvi on 9/20/2007 11:10:01 AM
This is a wonderful article. helped me a lot. Many thanks to Author
 
Posted by ewr on 9/21/2007 12:51:46 PM
erw
 
Posted by conga on 9/24/2007 10:17:37 AM
nice topic but can u explain why but this gridview inside updatepanel it is very slow in changing mode ? Tks
 
Posted by rekha on 10/10/2007 8:27:01 AM
Exellent article.....u have used very standard method with UML approach. This is the first time M writing comment for anybody. Thanks a lot...... Can u plz provide me a sample project in .net. Please if u can.... Thanks & Regards
 
Posted by chirag on 10/16/2007 12:36:54 AM
Very helpful examples..thanks a lot dude..wonderful one
 
Posted by Lily on 10/16/2007 12:37:44 AM
Excellent article.....but how to handle paging , i use below code but not working.......in vb.net Protected Sub GridView1_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles GridView1.PageIndexChanging GridView1.PageIndex = e.NewPageIndex GridView1.DataBind() End Sub Any idea ?
 
Posted by Shrihit on 10/17/2007 7:58:09 AM
Great article. I was wondering if you could send me the source code. Thanks
 
Posted by Viral Parmar on 10/18/2007 7:10:26 AM
Good article, really helhpful if using 3-Tier Architecture for development.
 
Posted by rajitha on 10/18/2007 7:16:26 AM
it's an Excellent article. could u plz send source code for different ways of using combos & textboxs on the Grid.
 
Posted by Saqib Siddiqui on 10/19/2007 4:04:39 PM
Great article. I like the way he explain things. Great Job
 
Posted by U.JankiRao on 10/24/2007 7:01:36 AM
Nice Very nice.. More than one expects
 
Posted by ritu on 10/28/2007 1:58:41 PM
your article was something i had been searching long thnks
 
Posted by ethan on 10/28/2007 8:04:48 PM
This is a very useful tutorial. Thank you very much. Is it possible to have all the source code? I did try to implement the rest of the code but some part does not work. Thanks.
 
Posted by Abhijeet Shastry on 10/29/2007 6:12:00 AM
I am trying to implement this code in vb.net but some errors are occuring. If u have this example in vb.net then could u send me this. Thanx
 
Posted by manjeev on 10/29/2007 7:33:25 AM
kindly disclosed your class methoed
 
Posted by jane on 10/29/2007 11:13:40 AM
Great article!!Can you please send to me the complete source code / project file? Thanks.
 
Posted by kaharba on 10/31/2007 6:50:04 AM
FATAFATI !
 
Posted by Shridhar on 10/31/2007 7:07:46 AM
Its very Nice.... Could u please send me a copy of standard Project in .net which will have all the business logic in it.
 
Posted by gopal on 11/1/2007 4:31:39 AM
A very Nice Article. Thanks.
 
Posted by Prabhakaran on 11/1/2007 8:43:28 AM
It is very Nice article........it helps to my project.... thxs
 
Posted by sri on 11/5/2007 6:23:29 AM
wonderful site..
 
Posted by good article on 11/5/2007 10:38:47 AM
Very nice article. One of the best for gridview. Can you please send me the complete source code? Thank you
 
Posted by Geek on 11/7/2007 3:03:09 AM
An Excellent Article!!!!
 
Posted by FZ on 11/7/2007 10:42:49 AM
A very good article for Gridview.
 
Posted by SirReadAlot on 11/8/2007 4:12:40 AM
pls send me fullcode of this article Simple Insert, Select, Edit, Update and Delete in Asp.Net GridView control
 
Posted by syamala,pradeepa on 11/14/2007 5:24:47 AM
thankx for u r example it.s very usefull for me thanx again
 
Posted by pradeepa on 11/14/2007 5:27:49 AM
Hi...... ur Artical is very very helpful my team..... thankx so much... my friend.
 
Posted by Srinivas on 11/14/2007 5:50:37 AM
When I am Try to Click Delete Button then shuld be need to Confirm Message and in that popUp if i click cancel button then transaction is cancel How .............. Ple let me know............
 
Posted by Srinivas on 11/14/2007 5:50:43 AM
When I am Try to Click Delete Button then shuld be need to Confirm Message and in that popUp if i click cancel button then transaction is cancel How .............. Ple let me know............
 
Posted by Uma on 11/14/2007 7:02:06 AM
Excellent Aricle
 
Posted by Neha on 11/16/2007 5:38:54 PM
Cool..really great...everything worked for me...
 
Posted by kk on 11/19/2007 3:52:51 AM
Very good article
 
Posted by kk on 11/19/2007 3:53:24 AM
Very good article
 
Posted by indra on 11/19/2007 2:03:43 PM
very very good article specially for begineers thanx a lot
 
Posted by Jabir on 11/19/2007 10:34:13 PM
It is an excellent article, am really very much impressed as I'm a beginner in ASP.Net.It is very useful and it touches most of the features of Gridview.
 
Posted by Jabir on 11/19/2007 10:34:24 PM
It is an excellent article, am really very much impressed as I'm a beginner in ASP.Net.It is very useful and it touches most of the features of Gridview.
 
Posted by Jose on 11/23/2007 3:20:19 PM
Very Helpful!!! Thanks but i would like to see all the source code!! maybe it helps me a lot!!! I appreciate you if you do it!!
 
Posted by Raghunath on 11/28/2007 4:07:05 AM
my question is i am facing a lot of problems when i working out on dynamically created columns i can read the data from the textboxes and i am unable save it.give me some examples on this concept
 
Posted by Daniel on 11/28/2007 12:34:10 PM
Do you have a solution for paging with gridview? Thank you for this tutorial
 
Posted by akeop on 11/30/2007 12:55:23 PM
Excellent. This was exactly what I was looking for
 
Posted by karthikeyan on 12/3/2007 10:46:51 PM
godd
 
Posted by Muruga on 12/9/2007 1:14:23 AM
This is very useful for me thank u
 
Posted by Mandar on 12/11/2007 1:19:20 AM
It is an excellent article, am really very much impressed as I'm a beginner in ASP.Net.It is very useful and it touches most of the features of Gridview. Excellent Fatafati.
 
Posted by Yogendra on 12/11/2007 4:32:20 AM
actually i want to know how we can show update and cancel buttons when we make a click on the edit button of the grid view? i want this answer in terms of asp.net and c#
 
Posted by Meenakshisundaram on 12/14/2007 2:13:55 AM
datagrid edit update how to work please send my id
 
Posted by anjay kumar on 12/14/2007 5:58:35 AM
Excellent
 
Posted by anjay kumar on 12/14/2007 5:58:50 AM
Excellent
 
Posted by rafi khan on 12/15/2007 10:23:13 AM
fine.
 
Posted by prem on 12/17/2007 5:48:01 AM
Thats a very good code snippet but one thing i would like to know that 1) can the same job be done without using the AJAX tools or any changes r required, if any do mail bye
 
Posted by rteter on 12/17/2007 9:21:49 AM
geggdagadgadggagggga
 
Posted by rteter on 12/17/2007 9:22:05 AM
fh
 
Posted by Manoj on 12/24/2007 8:19:37 AM
very nice article can i get source code?
 
Posted by HiteshShah on 12/26/2007 10:47:57 PM
it very good i try it for 3 days but not done with this help i wiill done within 3 hours
 
Posted by Suchit on 12/31/2007 2:31:16 AM
thanks for your help. this is nice way to help all to learn more. once again thanks.
 
Posted by Abhishek on 1/1/2008 9:33:01 PM
my bad, i did not have if (!IsPostBack) for when the data was being populated on page load.
 
Posted by Suresh on 1/2/2008 11:23:01 PM
Very Good One
 
Posted by Srinu on 1/3/2008 10:21:02 PM
Hi Friend, very nice article plzzz could u send source code. it will be great if you give reply Best regards, srinu
 
Posted by Kaushal on 1/10/2008 6:31:14 AM
It is very nice article to understand the basic events of Grid View. How do we update our data using GridView. I am really very much impressed with this code.
 
Posted by ankur on 1/11/2008 2:46:35 AM
Great Job!!! I was exactly looking for this, can you please send me the full source code, it would be a great help in my current project. Thanks a lot.
 
Posted by d on 1/12/2008 1:24:19 PM
desdffsdf fsd f sdf sd f sd fsd f sd fsd f sd f sdf sd f sd d fsdlçfkdlçskflksdlçflçsdklçfklçsdk ksdflçkflçsdklçfklsdçkflçsdkflçsd
 
Posted by Mark on 1/13/2008 11:19:08 AM
Hey Moderator1. Do you read the comments? Post the entire source code already! PLEASE :-)
 
Posted by pradeep on 1/22/2008 2:44:19 AM
very good! hi i m begineer in asp.net 2.0, it's useful for my project but can you provide me in html code for that, meance how to take gridview1_rowdeleting, gridview1_rowcommand, in html etc.
 
Posted by suresh on 1/22/2008 4:46:24 AM
it is very useful for the people who are learning asp.net 2.0.
 
Posted by Sudarshan on 1/22/2008 12:44:13 PM
Excellent article!
 
Posted by prmod on 1/24/2008 4:23:19 AM
it is very usefull for me .... thankx for it
 
Posted by prmod on 1/24/2008 4:23:31 AM
it is very usefull for me .... thankx for it
 
Posted by suresh on 1/24/2008 10:09:39 AM
thanks a ton, excellent...........
 
Posted by Shivendra singh on 1/25/2008 6:53:12 AM
Dear Sir, I am working on .net tech. but i dont know that how to display images on Gridview and Onmouse Event Images should be Large.
 
Posted by Shivendra singh on 1/25/2008 6:54:00 AM
Dear Sir, I am working on .net tech. but i dont know that how to display images on Gridview and Onmouse Event Images should be Large
 
Posted by Bala on 1/28/2008 6:44:09 AM
really good article .. thanks
 
Posted by chet on 1/28/2008 11:32:02 PM
Not good.There i s no need to use update panel . And there are so many things whicjh makes code lenthy.Any way let the foolish people apreciate u.
 
Posted by mark coates on 1/29/2008 8:03:35 PM
Please send me source code too. thanks great article
 
Posted by kish on 1/30/2008 5:00:06 AM
its nice
 
Posted by Prakash Selvaraj on 1/31/2008 12:52:57 AM
thanks great article..Please send me source code too.
 
Posted by kal on 1/31/2008 1:19:12 AM
nice article. Can you provide me source code to disable textbox via dropdownlist in a Gridview footer template while adding new record.
 
Posted by jeremy on 1/31/2008 11:36:15 PM
I have it setup like that, but for some reason edit update, the new value is not being passed into the textbox control so i can update the database...anybody have any idea as to the reason for this?
 
Posted by Yogesh Jadhav on 2/7/2008 2:20:34 AM
Really thank's for your article .It is Very useful for me really thank with my heart. Can you please send me all the codes in details which will be helpful for the biginner?
 
Posted by Yogesh Jadhav on 2/7/2008 2:20:54 AM
Really thank's for your article .It is Very useful for me really thank with my heart. Can you please send me all the codes in details which will be helpful for the biginner?
 
Posted by Yogesh Jadhav on 2/7/2008 2:21:29 AM
Really thank's for your article .It is Very useful for me really thank with my heart. Can you please send me all the codes in details which will be helpful for the biginner?
 
Posted by Nwoye E. Friday on 2/7/2008 4:03:08 AM
The article is good, is it possible for me to get the complete project folder? Thanks in advance.
 
Posted by Parthasarathi on 2/11/2008 6:50:44 AM
It's fine... I saw the sample gridview... It is very useful to me... I am new to this tech(.net)... Can I have the complete project source code.. Especially database manipulation class file ‘CustomersCls.cs’ ... please do the needful...
 
Posted by Ravi vyas on 2/13/2008 1:22:24 AM
Excellent. can you please send to me the complete source code / project file? Thanks. Eddie
 
Posted by Hello on 2/14/2008 11:55:53 PM
vry nice sir, it's vry useful for begneers.
 
Posted by Hello on 2/14/2008 11:56:09 PM
vry nice sir, it's vry useful for begneers.
 
Posted by Jamaldeen on 2/26/2008 4:42:50 AM
It is very good and best ..
 
Posted by karthik on 2/26/2008 7:36:32 AM
wow!!! really fanastatic !!! could u please the full code of the above sample!!!
 
Posted by karthik on 2/26/2008 7:38:23 AM
wow!!! really fanastatic !!! could u please the full code of the above sample!!!
 
Posted by rameshkumar on 2/27/2008 4:24:54 AM
WOWWWWWWWWWWW !!!!!!!! Excellent..........
 
Posted by rameshkumar on 2/27/2008 4:37:26 AM
WOWWWWWWWWWWW !!!!!!!! Excellent..........
 
Posted by karthik on 2/28/2008 12:29:04 AM
really super !!could you please send the sample code to my ID
 
Posted by Tarun on 3/3/2008 6:41:32 AM
woooooaaaauuuu ............ wanna articals ER ........... can u send me its full solutions .......... then i will be very very greatfull to u
 
Posted by D2 on 3/3/2008 10:31:56 AM
Great !!! 10O Points and Thank you !
 
Posted by Anand on 3/5/2008 4:59:21 AM
It's very useful for me.Thank You
 
Posted by Anand on 3/5/2008 4:59:32 AM
It's very useful for me.Thank You
 
Posted by Leon on 3/5/2008 6:43:22 AM
Please, send the solution! I don't get it work!
 
Posted by Leon on 3/5/2008 6:43:31 AM
Please, send the solution! I don't get it work!
 
Posted by kavitha on 3/6/2008 5:14:37 AM
It helped me alot a nice article
 
Posted by Surinder on 3/11/2008 7:18:54 AM
Hi Moderator1, Request: can you please send the entire project of "Simple Insert, Select, Edit, Update and Delete in Asp.Net GridView control" actually I am right working on the same and have been stuck up. . If you can send me the entire project along with the code it will really be usefull because my dead line is given and I am stuck at this point.
 
Posted by RamKaran Rajput on