Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to insert text in GridView ?

How to insert text in GridView ?

Scheduled Pinned Locked Moved C#
tutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    squattyarun
    wrote on last edited by
    #1

    I want to insert text in gridview but i dont have any data source. How can I insert text values in dataGridview? for example if i want to insert value in textbox i will user textBox1.text="Adfsr" like in the same way i want to create a gridview i have two columns viz Name and description in datagridview and I want to insert in "Arun" in name field and "Healthy person" in description. please suggest. I want to use dataGridview only....

    Arun Singh Noida.

    V 1 Reply Last reply
    0
    • S squattyarun

      I want to insert text in gridview but i dont have any data source. How can I insert text values in dataGridview? for example if i want to insert value in textbox i will user textBox1.text="Adfsr" like in the same way i want to create a gridview i have two columns viz Name and description in datagridview and I want to insert in "Arun" in name field and "Healthy person" in description. please suggest. I want to use dataGridview only....

      Arun Singh Noida.

      V Offline
      V Offline
      Venki56
      wrote on last edited by
      #2

      First You should take 2 textboxes and one button.. then write the following code Globally.... static DataSet ds = new DataSet(); static DataTable dt=new DataTable(); and in pageload event you should paste this code if(!IsPostBack) { dt.Columns.Clear(); ds.Clear(); dt.Rows.Clear(); dt.Columns.Add("Name"); dt.Columns.Add("Number"); ds.Tables.Clear(); ds.Tables.Add(dt); DataGrid1.DataSource =ds; DataGrid1.DataBind(); } and Write code for button1.. DataRow r=dt.NewRow(); r[0]=TextBox1.Text; r[1]=TextBox2.Text; ds.Tables[0].Rows.Add(r);// dt.Rows.Add(r); DataGrid1.DataSource =ds; DataGrid1.DataBind();

      venki

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups