Adding items to DataGrid in runtime
-
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
-
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
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
-
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
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
-
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
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!
-
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!