position of user control on a asp.net page

G

Guest

I am using the page_load event to load a user control within a place holder
control and display it on a page. Then I use response.write statements to
loop through the rows of a data table and display the contents on the page.
However, the contents of the table always appear above the user control
instead of being below the control. How can I place the contents of the tabe
below the place holder. See sample code below:

sub page_load(source as object, e as eventargs) Handles MyBase.Load
plcheadbanner.Controls.Add(LoadControl("MainBanner.a Dim
ds As New DataSet()
Dim myconn As String =
ConfigurationSettings.AppSettings.Item("ConnectionString")
Dim cnn As OleDbConnection
Dim stremail
stremail = Session("Emailid")
cnn = New OleDbConnection(myconn)
Dim dp As New OleDbDataAdapter("Select * from [project
permissions] where email = '" & stremail & "'", cnn)
cnn.Open()
Dim userinfotb As DataTable
Dim loop1, numrows As Integer
dp.Fill(ds)
userinfotb = New DataTable()
userinfotb = ds.Tables(0)
numrows = userinfotb.Rows.Count
If numrows = 0 Then
Response.Write("<p>There are NO Projects assigned to
you at this moment</p>")
Else
For loop1 = 0 To numrows - 1
Response.Write((userinfotb.Rows(loop1).Item("project
ID")) & "<br>")
Next loop1
End If
cnn.Close()
End Sub
 
K

Kevin Spencer

Response.Write is not OOP.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
T

Tampa.NET Koder

Dont use response.write. You could save your message in a string variable
or stringbuilder vairable, then write the contents to a Literal Control or
Label that you have positioned on your .aspx page.
 
G

Guest

Can you please recommend then what should be used instead of response.write

Kevin Spencer said:
Response.Write is not OOP.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

sagars76 said:
I am using the page_load event to load a user control within a place holder
control and display it on a page. Then I use response.write statements to
loop through the rows of a data table and display the contents on the
page.
However, the contents of the table always appear above the user control
instead of being below the control. How can I place the contents of the
tabe
below the place holder. See sample code below:

sub page_load(source as object, e as eventargs) Handles MyBase.Load
plcheadbanner.Controls.Add(LoadControl("MainBanner.a Dim
ds As New DataSet()
Dim myconn As String =
ConfigurationSettings.AppSettings.Item("ConnectionString")
Dim cnn As OleDbConnection
Dim stremail
stremail = Session("Emailid")
cnn = New OleDbConnection(myconn)
Dim dp As New OleDbDataAdapter("Select * from [project
permissions] where email = '" & stremail & "'", cnn)
cnn.Open()
Dim userinfotb As DataTable
Dim loop1, numrows As Integer
dp.Fill(ds)
userinfotb = New DataTable()
userinfotb = ds.Tables(0)
numrows = userinfotb.Rows.Count
If numrows = 0 Then
Response.Write("<p>There are NO Projects assigned to
you at this moment</p>")
Else
For loop1 = 0 To numrows - 1
Response.Write((userinfotb.Rows(loop1).Item("project
ID")) & "<br>")
Next loop1
End If
cnn.Close()
End Sub
 
J

John Timney \(ASP.NET MVP\)

Use something like a datagrid bound to your dataset

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

sagars76 said:
Can you please recommend then what should be used instead of response.write

Kevin Spencer said:
Response.Write is not OOP.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

sagars76 said:
I am using the page_load event to load a user control within a place holder
control and display it on a page. Then I use response.write statements to
loop through the rows of a data table and display the contents on the
page.
However, the contents of the table always appear above the user control
instead of being below the control. How can I place the contents of the
tabe
below the place holder. See sample code below:

sub page_load(source as object, e as eventargs) Handles MyBase.Load
plcheadbanner.Controls.Add(LoadControl("MainBanner.a Dim
ds As New DataSet()
Dim myconn As String =
ConfigurationSettings.AppSettings.Item("ConnectionString")
Dim cnn As OleDbConnection
Dim stremail
stremail = Session("Emailid")
cnn = New OleDbConnection(myconn)
Dim dp As New OleDbDataAdapter("Select * from [project
permissions] where email = '" & stremail & "'", cnn)
cnn.Open()
Dim userinfotb As DataTable
Dim loop1, numrows As Integer
dp.Fill(ds)
userinfotb = New DataTable()
userinfotb = ds.Tables(0)
numrows = userinfotb.Rows.Count
If numrows = 0 Then
Response.Write("<p>There are NO Projects assigned to
you at this moment</p>")
Else
For loop1 = 0 To numrows - 1
Response.Write((userinfotb.Rows(loop1).Item("project
ID")) & "<br>")
Next loop1
End If
cnn.Close()
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top