getting the data for dynamically for Datagrid

S

sri kanth

hi ,
i am displaying the datagrdig (dg) headers dynamically..
now i just want to know how to display the data from a dataset to my
datagrid..

for i=0 to Ds.tables(0).rows.count-1
dg.columns(i).HeaderText=ds.tables.rows(i).item(0)
next

now tell me if i had a dataset where i need to pass the
HeaderText value to my sql query so that it will display the
corresponding value to the header text...
pls if any one know this help me..
it is very urgent..
thanks & regards
srikanth
 
R

R. Thomas, aka Xtreme.Net

I dont really understand what you are trying to say...
First you gave the code to bind dataset to headers, then u are asking how to
do that?
huh??????
R. Thomas
 
S

sri kanth

hi,
i am giving the code to u ....

Public Sub GetTemplateColumns()
Dim icount, i, j, k As Integer
Dim strFinishDate As String
Dim str As String
Dim FinishDate As DataSet
Dim tc As TemplateColumn
Dim HeaderText As String

SBUTaskList =
ObjMileStoneReport.fn_SBUTaskList(cmbSbuNames.SelectedItem.Value,
Trim(cmbYear.SelectedItem.Text))
Session("SBUTaskList") = SBUTaskList
For icount = 0 To SBUTaskList.Tables(0).Rows.Count - 1
HeaderText = SBUTaskList.Tables(0).Rows(icount).Item(0)
tc = New TemplateColumn()
strFinishDate = ""
For i = 0 To DsReport.Tables(0).Rows.Count - 1
str &= DsReport.Tables(0).Rows(i).Item(0) & "-"
FinishDate =
ObjMileStoneReport.fn_GetBaseLineFinishDate(DsReport.Tables(0).Rows(i).I
tem(0), Trim(HeaderText), Trim(cmbYear.SelectedItem.Text))
For k = 0 To FinishDate.Tables(0).Rows.Count - 1
strFinishDate = strFinishDate &
Left(objDate.InvertDateMonth(FinishDate.Tables(0).Rows(k).Item(0)), 10)
& "-"
Next
Next
tc.HeaderTemplate = New
DataGridTemplate(ListItemType.Header, Trim(HeaderText), str)
tc.ItemTemplate = New DataGridTemplate(ListItemType.Item,
HeaderText, str)
dgMilestoneReport.Columns.Add(tc)
Next

dgMilestoneReport.DataSource = DsReport
dgMilestoneReport.DataBind()

Public Class DataGridTemplate
Implements ITemplate
Dim TemplateType As ListItemType
Dim ProjectName As String
Dim strproj As String()
Dim kc As Integer
Dim ii As String
Dim ColumnName As String
Dim Year As String
Dim obj As New clsMilestoneReport()

Sub New(ByVal type As ListItemType, ByVal ColName As String,
ByVal ProjName As String)
TemplateType = type
ColumnName = ColName
ProjectName = ProjName
'Year = Year
End Sub
Sub InstantiateIn(ByVal Container As Control) Implements
ITemplate.InstantiateIn
Dim lc1 As LiteralControl = New LiteralControl()
Dim dc As DataGridItem

Select Case TemplateType
Case ListItemType.Header
lc1.Text = ColumnName
Container.Controls.Add(lc1)
Case ListItemType.Item
lc1.Text = ProjectName
Container.Controls.Add(lc1)
 
R

R. Thomas, aka Xtreme.Net

Slow down, I asked whats your question, and you are throwing code at me... I
still dont know what the question is....
R. Thomas
 

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,769
Messages
2,569,582
Members
45,067
Latest member
HunterTere

Latest Threads

Top