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. Visual Basic
  4. Adding items to DataGrid in runtime

Adding items to DataGrid in runtime

Scheduled Pinned Locked Moved Visual Basic
csharp
5 Posts 3 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.
  • U Offline
    U Offline
    User 2232424
    wrote on last edited by
    #1

    I have one datagrid for fetch and display the values from the table. I need to adding items to datagrid at runtime using vb.net. I want the code. my code is Dim con As SqlClient.SqlConnection Dim Cmd As SqlClient.SqlCommand Dim da As SqlDataAdapter Dim ds As New DataSet Dim constring As String = "data source=ccs10; initial catalog=gcis;user id=jpa;password=jpa" Private Sub Btn_Raise_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Raise.Click Dim CoMm As String con = New SqlClient.SqlConnection(constring) cmd=new sqlclient.sqlcommend("Select * from Paperrfq") da = New SqlClient.SqlDataAdapter(cmd) da.Fill(ds, "paperrfq") DataGrid1.DataSource = ds.DefaultViewManager aruljothi

    B 1 Reply Last reply
    0
    • U User 2232424

      I have one datagrid for fetch and display the values from the table. I need to adding items to datagrid at runtime using vb.net. I want the code. my code is Dim con As SqlClient.SqlConnection Dim Cmd As SqlClient.SqlCommand Dim da As SqlDataAdapter Dim ds As New DataSet Dim constring As String = "data source=ccs10; initial catalog=gcis;user id=jpa;password=jpa" Private Sub Btn_Raise_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Raise.Click Dim CoMm As String con = New SqlClient.SqlConnection(constring) cmd=new sqlclient.sqlcommend("Select * from Paperrfq") da = New SqlClient.SqlDataAdapter(cmd) da.Fill(ds, "paperrfq") DataGrid1.DataSource = ds.DefaultViewManager aruljothi

      B Offline
      B Offline
      BORN again
      wrote on last edited by
      #2

      Can you please be more specific on the nature of your problem? Please tell more about your data fields that you need to display. I am saying this because I do this all the time and maybe I can help you. Aartee. ...HE is watching Us All! -- modified at 3:02 Tuesday 30th August, 2005

      U 1 Reply Last reply
      0
      • B BORN again

        Can you please be more specific on the nature of your problem? Please tell more about your data fields that you need to display. I am saying this because I do this all the time and maybe I can help you. Aartee. ...HE is watching Us All! -- modified at 3:02 Tuesday 30th August, 2005

        U Offline
        U Offline
        User 2232424
        wrote on last edited by
        #3

        hello mam, Thanks for ur reply.i am a beginner in dotnet.i wud like to know about the data grid functionality.my requirement is i should be able to view the data in the datagrid from the database as well i want to enter new data in the same data grid to update my database.is this possible in vbdotnet and pls help me in getting things right. I have more datafields in a table and display that in a datagrid. Datafields are Empno as integer,empname as string thank u aruljothi

        B 1 Reply Last reply
        0
        • U User 2232424

          hello mam, Thanks for ur reply.i am a beginner in dotnet.i wud like to know about the data grid functionality.my requirement is i should be able to view the data in the datagrid from the database as well i want to enter new data in the same data grid to update my database.is this possible in vbdotnet and pls help me in getting things right. I have more datafields in a table and display that in a datagrid. Datafields are Empno as integer,empname as string thank u aruljothi

          B Offline
          B Offline
          BORN again
          wrote on last edited by
          #4

          Hi ArulJothi, ---my requirement is i should be able to view the data in the datagrid from the database as well i want to enter new data in the same data grid to update my database.is this possible in vbdotnet --- Yes it is possible to view the data as well as to update it. There are a couple of ways to do it, 1.In your SQL statement write a select stt to display the fields you need in the datagrid, do the rest of databse-connectivity,bindgrid() etc..coding. In your datagrid include a 'Hyperlink' column for 'change/Update Form' and redirect the link to your actual form by providing a 'URL' in the url field of the Property Builder i.e. Propertybuilder-->columns-->hyperlink column--> HeaderText:Change/Update-->text:Update-->URLField:[your primary key of the form/table]eg:formNo-->URLFormat string:[your original form name not the datagrid one]eg: formname.aspx?formno={0} this way your datagrid will bring you straight back to the form, you can make changes and save and the changes will be reflected in the datagrid. 2. Add the 'Edit,Update,Cancel' button and write the sub say, updatetable for update and edittabel for edit on the datagrid code behind page, include OnUpdatecommand="updatetable" and Oneditcommand="edittable" in the HTML page. so this will edit the columns and you can make changes to the fields you included in your datagrid(not form) and update it. I hope this helps .let me know if you need more clarifications on any of the above. good luck. Aartee. ...HE is watching Us All!

          K 1 Reply Last reply
          0
          • B BORN again

            Hi ArulJothi, ---my requirement is i should be able to view the data in the datagrid from the database as well i want to enter new data in the same data grid to update my database.is this possible in vbdotnet --- Yes it is possible to view the data as well as to update it. There are a couple of ways to do it, 1.In your SQL statement write a select stt to display the fields you need in the datagrid, do the rest of databse-connectivity,bindgrid() etc..coding. In your datagrid include a 'Hyperlink' column for 'change/Update Form' and redirect the link to your actual form by providing a 'URL' in the url field of the Property Builder i.e. Propertybuilder-->columns-->hyperlink column--> HeaderText:Change/Update-->text:Update-->URLField:[your primary key of the form/table]eg:formNo-->URLFormat string:[your original form name not the datagrid one]eg: formname.aspx?formno={0} this way your datagrid will bring you straight back to the form, you can make changes and save and the changes will be reflected in the datagrid. 2. Add the 'Edit,Update,Cancel' button and write the sub say, updatetable for update and edittabel for edit on the datagrid code behind page, include OnUpdatecommand="updatetable" and Oneditcommand="edittable" in the HTML page. so this will edit the columns and you can make changes to the fields you included in your datagrid(not form) and update it. I hope this helps .let me know if you need more clarifications on any of the above. good luck. Aartee. ...HE is watching Us All!

            K Offline
            K Offline
            kpsetty
            wrote on last edited by
            #5

            hi, i think u said for web application, may i get the solution for window application to add/update/delete at runtime

            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