.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

how to insert a non databound row in a gridview

Posted By:      Posted Date: September 23, 2010    Points: 0   Category :ASP.Net

Hi friends,

can anybody help doing this, i have to a grid view and the datasource for it is a table coming from the database the table containing sequence numbers for example if the sequence number is 1 then i want to add a row just above this saying it is the start , the entire row should give some information .

i tried to find related thing but no luck, waiting for some replies to move further



View Complete Post

More Related Resource Links

Insert Rows with a GridView

In ASP.NET version 1.x, I used the footer on the DataGrid control to insert new rows by placing a series of TextBox, DropDownLists, CheckBoxes etc. controls on it and then handling a save button. This also works with the GridView in version 2.0 but with one major exception: if your data source is empty, the GridView will hide your footer (and header) and only display the EmptyDataText.

insert the data in database using gridview jquery



I want to use gridview and bind the data and after i want insert the data in database using jquery,

below the link i got for delete


but i want the sample example for insert  row from gridivew and add the database.


Custom Grid View Header - Grid view Row Created event vs Gridview row databound events ?


Hi Gurus ,

It happened to add an extra Gridveiw Header in row_databound event , It did worked fine on !Postback but disappered on Page.Postback . Quick google search guided me to move the event to Row_Created event and every thing is okay .

Can any expert post some pointers , differnces between grid row_created vs row_databount with some sample table data created dynamically  behaviour of both the events in !Postback and page.Postback .

Thanks a tonne in Advance and  any inputs will be valued and appreciated .

Insert data based on gridview user value on row.. how to



I have three column comes from database table(Table1) and one column is for entering data for the user let us consider it look like this 

ItemNo ItemName Qty  uservalue

001       A               50       20

002       A               20       5

003       B               50  

004       C               60      10

005       D               40 

006       E               90      15 


If its 300 row from database to gridview it will show 50 record with page navigation..

What i need is i need to insert data in to database table which gridview row has user value..

The output of the another table(Table2) will look like this after insert

ItemNo ItemName   uservalue

001       A                    20

002       A                      5  

hsdsd: how to insert two values from text box1 to gridview g



table a

a                                 b

jhgd                           kljhskjd

sdghdshgd                 jkhdjhdjk

what i need is when enter some values(varchar ) in txt 1 and 2

it should be added in database and shown in gridview1 after i press butt1


any bodyknows full code answer/akdj

Can't change Gridview row colors or styles in the DataBound event


I was highlighting certain rows in my gridview using code like this in the DataBound event:

        if (e.Row.RowType == DataControlRowType.DataRow)
            int vendorCheck = 0;
            //TODO make this shorter
            if (DataBinder.Eval(e.Row.DataItem, "vendorId") != System.DBNull.Value)

Insert columns into GridView and rendercontrol error

Hi I´m inserting columns into a gridview at run time using: gvRageReport.Columns.Insert(index, column) When I render the gridview in orther to export to excel all the excel columns are empty except the new insert columns, but when I add the new columns using gvRageReport.Columns.Add(column) the excell is exported successfully.Any idea?

GridView Insert clicking a button in footer row using stored procedure


Hi!! I need your help again.

I have a gridview with a button in the first column of the footer row and some controls (textbox, dropdowlist...) in the rest of the columns. I want to click that button and insert into a database table using an stored procedure the text properties of the controls in the other columns.

I don't know what's wrong... could you help me or post me a link to read it??

I'm setting the insert command with my stored procedure, I'm setting the storedprocedure as the insertcommandtype, I'm able to load the controls with correct values, but finally when I click the insert button that's not work!!!!

Thank you!!!

Gridview insert



i want to insert the new row in gridview. Please tel me how to do that and that data should also be updated in my table.....

Tricky Insert Logic for dynamically created row in GridView.


Hi, and thanks for peeping the query i have.

I am dynamically generating the Row in GridView and saving the data in database using StringCollection. Instead of using StringCollection i want to pass the data(user entered data) to local variable , eg:

string name = txtFName; and so on. but it wont work for dynamically created rows.

So if you knw how to assign the user provided data in the local variable like above i have show, please help me out. 

The code for inserting the records for dynamic created rows in grid view via StringCollection is below


protected void btnSave_Click(object sender, EventArgs e)


        int rowIndex = 0;

        StringCollection sc = new StringCollection();

        if (ViewState["CurrentTable"] != null)


            DataTable dtCurrentTable = (DataTable)ViewState["CurrentTable"];

            if (dtCurrentTable.Rows.Count > 0)


How to INSERT GridView data into another table (besides the one it is bound to)??


Hi All,

I have a tricky situation that I just cannot seem to figure out.  I'm using ASP.NET 4.0.  I have two databases (let's call them Northwind and MyDatabase for simplicity).  I cannot modify the data in Northwind, but once I save a copy to MyDatabase, I can change it.

I have a GridView that shows all the tests associated with a patient.  I first populate the GridView, retrieving all the tests in Northwind.Test that are associated to a PatientID.  On a button click event, I need to:

  1. Create a new Patient record in MyDatabase.Patient (I've got this part done already).
  2. Use that newly created PatientID and INSERT all of the rows from the GridView into MyDatabase.Test.  I have the PatientID available, I just don't know how to retrieve the data from the GridView.
  3. (Ideally) I would like to then be able to load that patient record in the future from MyDatabase and be able to UPDATE the tests in the GridView to MyDatabase.Test.

I can load the tests into the GridView no problem.  But I have no idea how I would save that data to a different datasource.  Any ideas?  Should I even be using a GridView, or something else?

-Thanks in advance-

Gridview refresh after databound changes


I've been working on a colleagues site, and have been unable to fix a coupld of issues with it.  One of which is a refresh of a Gridview panel.

The page allows a user to navigate a tree structure and then display the permissions on a user selected folder.  Permissions are then added/removed and Saved.

What's not happening is the saved changes aren't being refreshed in the Gridview, also after doing this process once selecting another folder doesn't refresh the Gridview either.

 Below is the sa.aspx file

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="sa.aspx.cs" Inherits="sa" Debug="true" %>

<%@ Register Assembly="System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
    Namespace="System.Web.UI" TagPrefix="asp" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<%@ Import Namespace="System.Web.Services" %>
<%@ Import Namespace="System.Web.Script.Services" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.

Bulk Insert into Access Database not working for template fields in gridview



I have a gridview with 5 columns

4 are fetched from database through select command from table CSDB_MASTER

5th is a template field textbox which consists of value 3 by default

now i have a button down to the gridview with the following code below

everything is being inserted except the value of textbox, when i open my database the field NOC which should be inserted with grv.cells[5].Text i.e, the textbox value is null

Please Help Me Out in this issue


protected void Button1_Click(object sender, EventArgs e)

        OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\masterdb.accdb;Persist Security Info=False;");
        OleDbCommand cmd = new OleDbCommand();
        cmd.Connection = con;

        foreach (GridViewRow gvr in GridView1.Rows)

Bulk insert into access database not working with template fields in gridview


how to insert data into access database from gridview containing template fields

insert data by gridview



Can you tell me, how can I implement gridview and one of the coulumn of this gridview is textbox

from the textbox I can insert the data in to the database

then  click to save button to save all data I inserted

Thanks for ur help 

How to perform insert, update, delete and select rows in ASP.NET gridview control using stored proce

In this article, we will explore how to add, update, delete and select a record from sql server database using gridview control in a simple way. I'm using visual studio 2010 and sql server 2008 for this sample.

Inplace Edit in GridView

In this article I am presenting a different way to look at EditItemTemplate, using which user navigation for editing is reduced and . it looks very different (see screeen shots) then regular implementation of GridView.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend