datagrid columns

G

Guest

I have a datagrid that's using a dataread to display rows from SQL Server. I
have autogenerate columns turned off. When I add columns in code behind (VB),
I don't get the columns displayed correctly. If I add the columns in the web
page as part of the html, it works. I have other grids that work correctly
with the VB code, and have tried replacing the grid, building the page from
scratch, and still get the same result. Any ideas? Thanks in advance.
 
R

Ray Costanzo [MVP]

Not correctly in what way? Is the text upside down? Describe what's wrong
and show the code that you're using to produce the columns, please.

Ray at home
 
G

Guest

Not all of the columns are displayed (only 2 of 3) and style sheet isn't
applied. Here's the VB code:

ScheduleReader = cm.ExecuteReader
If ScheduleReader.HasRows Then
strSchedule = "Schedule"
dgSchedule.AutoGenerateColumns = False
Dim dgcDate As New BoundColumn
With dgcDate
.DataField = "SubjectDate"
.HeaderText = "Due Date"
.ItemStyle.CssClass = "SectionScheduleDate"
End With
dgSchedule.Columns.Add(dgcDate)
Dim dgcSubject As New BoundColumn
With dgcSubject
.DataField = "Subject"
.HeaderText = "Subject"
.ItemStyle.CssClass = "SectionScheduleSubject"
End With
dgSchedule.Columns.Add(dgcSubject)
Dim dgcComment As New BoundColumn
With dgcDate
.DataField = "Comment"
.HeaderText = "Comment"
.ItemStyle.CssClass = "SectionScheduleComment"
End With
With dgSchedule
.Columns.Add(dgcComment)
.DataSource = ScheduleReader
.DataBind()
End With
Else
strSchedule = "Schedule Not Available"
End If
ScheduleReader.Close()

Thanks for your help.
 

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

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top