SIGN UP MEMBER LOGIN:    
Blog

Insert data in Grid View without using database

Posted by Akash Gaur Blogs | ASP.NET Programming Feb 17, 2012
In this blog I have written the code for insert the data from textboxes into Grid View without using database.

Insert the data from the textbox into the Grid View without using any database  in ASP. NET using C#.

Step 1: To do this firstly open the Microsoft Visual Studio 2010 then click the File->New->Web Site->select the ASP. NET website.

1.jpg

Step 2: The design window get appears and create a Grid View control and  textbox control and  button control. And set the property of controls by using the property window.

2.jpg

3.jpg

Step 3:  Now double click on the button control to write the source code of its click event.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
            dt = new DataTable();
            DataColumn dc1 = new DataColumn("NAME");
            DataColumn dc2 = new DataColumn("ADDRESS");
            dt.Columns.Add(dc1);
            dt.Columns.Add(dc2);
            DataRow dr1 = dt.NewRow();
            GridView1.DataSource = dt;
            GridView1.DataBind();
    }
    DataTable dt;
    protected void Button1_Click(object sender, EventArgs e)
    {
        DataRow dr1 = dt.NewRow();
        dr1[0] = TextBox1.Text;
        dr1[1] = TextBox2.Text;
        dt.Rows.Add(dr1); 
        GridView1.DataSource = dt;
        GridView1.DataBind();
    }

}

Step 4: Run the application by pressing F5 keys and insert the value in the textboxes then click on the button.

The Output is as Follows:

4.jpg

5.jpg

share this blog :
post comment
 

Even how ordinary shoes, accompanied by gold and silver must be big hair glory. Smooth and almost shiny shoes, tie, face and heel has a unique design. Cute leopard printed on the cute girl shoes when love is hundred percent. Do not too much of the bow, would greatly eye-catching "Golden Flower" instead. Bright blue crocodile pattern has been highly lethal, Apple beaded toe equal surprise.Oxford shoes with a small tassel can be said on behalf of the casual, denim blue and pure white with, stylish and fresh. http://www.monsterearphoes.com/

Posted by JimJarmusch Jim Mar 15, 2012

It is so wonderful post....

Posted by Vineet Kumar Saini Feb 19, 2012