This message was discovered on ASPFriends.com 'aspngdatagridrepeaterdatalist' list.
| Bob Herrmann |
-- Moved from [aspngfreeforall] to [aspngdatagridrepeaterdatalist] by devin <Click here to reveal e-mail address> --
I want to select one row from my SQL table and then display each column in this table as a row in a datagrid. So I would have a SQL statement like "SELECT * FROM tabCustomer WHERE CustomerID=95" which returns one row. Now I want to display each column as a row in my datagrid. Can someone help me get started?
Thanks, Bob
|
|
| |
| | |
| |
| Greg Bernhardt |
sure
grab each row value you want by using the executescalar() method and make varaibles for each row value., underneath that place a Page.DataBind(). Then goto your aspx page and make a datagrid with a template form, inside each template include a <%# variable_name %>
hope that helps
-----Original Message----- From: Bob Herrmann [mailto:Click here to reveal e-mail address] Sent: Tuesday, August 13, 2002 10:11 AM To: aspngDataGridRepeaterDatalist Subject: [aspngdatagridrepeaterdatalist] Datagrid problem
-- Moved from [aspngfreeforall] to [aspngdatagridrepeaterdatalist] by devin <Click here to reveal e-mail address> --
I want to select one row from my SQL table and then display each column in this table as a row in a datagrid. So I would have a SQL statement like "SELECT * FROM tabCustomer WHERE CustomerID=95" which returns one row. Now I want to display each column as a row in my datagrid. Can someone help me get started?
Thanks, Bob | [aspngdatagridrepeaterdatalist] member Click here to reveal e-mail address = YOUR ID | http://www.aspfriends.com/aspfriends/aspngdatagridrepeaterdatalist.asp = JOIN/QUIT
|
|
| |
|
| |
| Bob Herrmann |
Thanks for everyone who responded to my post. I sort of have this thing working but I would like to add something. Right now, I sure enough have a row in my datagrid for each column in my table. But I would like to add another column to my datagrid that contains the column name. So I would like my datagrid to look like this:
CustomerID 1 CustomerName Bob Address1 123 Main St City Miami State FL
Presently, only the value prints and not the column names. I somehow have to get the column name text into my data table but this is my first attempt at data tables and I cannot seem to find out how to do this. Here is the code I have up this point:
Dim sSql As String = "SELECT * FROM tabCustomer WHERE CustomerID = 95"
Dim oConn As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("BOBSQL"))
Dim oAdapter As SqlDataAdapter
Dim oDS As DataSet
Dim oDT As DataTable = New DataTable("TempTab")
Dim ColCount As Integer
Dim oCol As DataColumn
Dim oRow As DataRow
Dim i As Integer
oConn.Open()
oAdapter = New SqlDataAdapter(sSql, oConn)
oDS = New DataSet()
oAdapter.Fill(oDS, "tabCustomer")
ColCount = oDS.Tables("tabCustomer").Columns.Count
oDT.CaseSensitive = False
oCol = oDT.Columns.Add("RowValue", System.Type.GetType("System.String"))
For i = 0 To ColCount - 1
oRow = oDT.NewRow
oRow("RowValue") = oDS.Tables("tabCustomer").Rows(0).Item(i)
oDT.Rows.Add(oRow)
Next
DataGrid1.DataSource = oDT
DataGrid1.DataBind()
oConn.Close()
----- Original Message ----- From: "Greg Bernhardt" <Click here to reveal e-mail address> To: "aspngDataGridRepeaterDatalist" <Click here to reveal e-mail address> Sent: Tuesday, August 13, 2002 11:30 AM Subject: [aspngdatagridrepeaterdatalist] RE: Datagrid problem
[Original message clipped]
|
|
| |
|
|
|
|
|