Simon,
You could do it that way... I found rather than abandon your ASP
experience, use the "Placeholder" control and just write the same
traditional HTML code in table format like you did in ASP...
You will likely need to use the Dataset Raghvendra suggests and you will
also want to add a Webform Button and have the clicks tracked on PostBack...
something like this (i hacked this from my code so code may not be
complete)...
Add Placeholder control to webform named "phGrid"
Private Sub LoadGrid(ByVal EID As Integer)
Dim strQuery As String
Dim oDA As SqlClient.SqlDataAdapter
Dim oDS As DataSet
Dim row As DataRow
Dim strOutput As New StringBuilder(1024)
Dim newLink As LinkButton
Try
oDS = New DataSet
strQuery = "Select * from Wherever Order By Whichever"
oDA = New SqlClient.SqlDataAdapter(strQuery,
MySvrConnectionString)
oDA.Fill(oDS, "MyData")
phGrid.Controls.Clear()
strOutput.Remove(0, strOutput.Length)
strOutput.Insert(0, "<table border=1 cellspacing=0 >")
phGrid.Controls.Add(New LiteralControl(strOutput.ToString)) '
output string to PHcontrol
For Each row In oDS.Tables("MyData").Rows
strOutput.Remove(0, strOutput.Length)
strOutput.Insert(0, " ")
strOutput.Append("<tr><td align=left>")
strOutput.Append(row("MyField1"))
strOutput.Append("</td><td align=center>")
phGrid.Controls.Add(New LiteralControl(strOutput.ToString))
newLink = New LinkButton
newLink.ID = "Delete" & row("MyUniqueRecordID")
newLink.Text = "Delete"
newLink.CommandArgument = row("MyField2")
AddHandler newLink.Click, AddressOf Delete_Click
phGrid.Controls.Add(newLink)
phGrid.Controls.Add(New LiteralControl("</td></tr>"))
Next
phGrid.Controls.Add(New LiteralControl("</table>"))
Catch ex As Exception
' output errors
Finally
If (Not oDA Is Nothing) Then
oDA.Dispose()
End If
If (Not oDS Is Nothing) Then
oDS.Dispose()
End If
End Try
End Sub
.... then be sure to create your "Delete_Click" sub to catch the postback and
delete the appropriate record from the table...
Hope this helps!
wardeaux
"Raghavendra T V" <ra*****@hotmail.com> wrote in message
news:ud**************@tk2msftngp13.phx.gbl...
Hi Simon,
The Best way i would choose is to play around with the DataSet in which
you have the Data
loop through the Dataset col / row collection in fashion that you want to
display. and build a new dataset and bind to Datagrid.
Thanks
Raghvendra
"simon" <si*********@stud-moderna.si> wrote in message
news:uA**************@TK2MSFTNGP10.phx.gbl... I get from database something like this:
DAY HOUR PRICE
---------------------------------------------
MONDAY 10 100
MONDAY 11 120
MONDAY 12 130
MONDAY 13 140
MONDAY 14 150
TUESDAY 11 90
TUESDAY 13 100
TUESDAY 15 110
TUESDAY 17 120
TUESDAY 18 130
TUESDAY 19 140
....................
Now, I would like to show this on the page like this:
TIME AND PRICE FOR MONDAY
--------------------------------------------
Time:10 Price:100 DELETE button
Time:11 Price:120 DELETE button
Time:12 Price:130 DELETE button
Time:13 Price:140 DELETE button
Time:14 Price:150 DELETE button
TIME AND PRICE FOR TUESDAY
--------------------------------------------
Time:11 Price: 90 DELETE button
Time:13 Price:100 DELETE button
Time:15 Price:110 DELETE button
Time:17 Price:120 DELETE button
Time:18 Price:130 DELETE button
Time:19 Price:140 DELETE button
and so on.
When user clicks DELETE button, the row is removed and deleted from the
database.
What is the best way to do this?
Data grid or data repeater?
Any example? I don't know how to construct it. In asp it was easy with
response.write method and recordset
Thank you,
S