macrost

msg:947927 | 6:32 am on May 12, 2006 (gmt 0) |
Can you paste the code that you are having problems with? It would be a lot easier to help you with this.
|
Kavkan

msg:947928 | 8:07 am on May 12, 2006 (gmt 0) |
Inherits System.Web.UI.Page Dim connstr As String = "data source=SERVER;initial catalog=DB;user id=USER;password=PASSWORD;" Dim sqlStr As String = "SELECT * FROM Users" Dim dt As New DataTable Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click dt.Clear() Dim dataAdapter As New SqlClient.SqlDataAdapter(sqlStr, connstr) dataAdapter.Fill(dt) dataAdapter.Dispose() dgDisplay.DataSource = dt End Sub Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click Dim changes As Integer Dim dataAdapter As New SqlClient.SqlDataAdapter(sqlStr, connstr) Dim commandBuilder As New SqlClient.SqlCommandBuilder(dataAdapter) changes = dataAdapter.Update(dt) dataAdapter.Dispose() If changes > 0 Then MsgBox(changes & " changed rows were stored in the database.") Else MsgBox("no changes made.") End If End Sub
|
TheNige

msg:947929 | 9:44 pm on May 12, 2006 (gmt 0) |
I believe you need to databind the datasource. dgDisplay.Databind
|
Kavkan

msg:947930 | 11:51 pm on May 12, 2006 (gmt 0) |
Thanks Nige! It displays the records properly, but it doesn't allow for direct editing of a particular record through the Data Grid. Is it possible to make the Web Application Data Grid identical to the Windows Application Data Grid(ie. to have the same functionality)? If so, would it require a change in the code or is it a configuration of the Data Grid element's parameters?
|
macrost

msg:947931 | 12:47 pm on May 15, 2006 (gmt 0) |
Well one thing that you would have to do is add a textbox control or whatever you want to the datagrid. (I don't have vs.net 2003 installed on this computer, sorry) Then you would iterate through all the items of the datagrid on save click. Datagrid Iteration [xmlpitstop.com] has a good expample on how to do that. I was looking at the code, and at the bottom when the example shows how to use the findcontrol method, I like to use DirectCast instead of the older CType, it is a bit faster, IMO.
|
TheNige

msg:947932 | 8:25 pm on May 15, 2006 (gmt 0) |
I suggest doing a search on the web for 4GuysFromRolla web site. They have something like a 17 part tutorial for the DataGrid control. The web control is similar in name to the Forms control, but they are a little different in what they do and how it works.
|
|