D
drdave
I need to output my data in a grid fashion but some of the cells will
have more than 1 record, I have been wrestling with the best solution
for this.
I need data in this fashion:
rowheader col1 col2 col3 col4
row1 data data data data
data data
data
row2 data data data
I am migrating an existing app so if you really want to see how I need
to output the data:
http://206.191.16.142/psait_spila/lmnec_eslc/eslc/salaire_minwage/report2/report2_e.cfm
I have loaded my jurisdiction column into a repeater and the years into
a datalist so I have my shell.
<table cellSpacing=0 cellPadding=0 width="90%" border=1>
<tr>
<th>Jurisdiction </th><asp:repeater id=rptYear runat="server">
<itemtemplate >
<th>
<%# Container.DataItem %>
</th>
</itemtemplate>
</asp:repeater></tr><asp:datalist id=dljurList runat="server"
cellpadding="0" cellspacing="0">
<itemtemplate>
<tr>
<td>
<%# Container.DataItem %>
</td>
<td>
<!--some control to outpu data properly here
-->
</td>
</tr>
</itemtemplate>
</asp:datalist>
</table>
But I need help on how to get my data into the table, I have used
looping constructs to get my data ordered in the proper fashion but
databinding the row does not work...
Object reference not set to an instance of an object.
I'm trying to fill a repeater or datalist when the year matches the
jursidiction, plus I have nulls, plus I have multiple records for some
years. My oop skills are weak so I have been trying to do this in a
procedural fashion.. and it aint workin .. any oop experts that can
show me the way, any help would be appreciated..
My code behind:
Public Class report2
Inherits System.Web.UI.UserControl
Protected rm As ResourceManager
Private yearparam As Integer =
httpContext.Current.Request.QueryString("dec")
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
'Setup the proper decade parameters
Dim YearArrList As New ArrayList (10)
'Setup the prov list for looping through later
Dim ProvArrList As New ArrayList
Dim ProvNameList As New ArrayList
Dim DBDataView As DataView
Dim stryear_from As String
Dim stryear_to As String
Dim intyear_from As String
Dim intyear_to As String
Dim i as Integer
Select Case yearparam
Case 1
'Declare strings to pass as db params
stryear_from = "1965/01/01"
stryear_to = "1974/12/31"
'Declare strings for array params
intyear_from = "1965"
intyear_to = "1974"
Case 2
stryear_from = "1975/01/01"
stryear_to = "1984/12/31"
intyear_from = 1975
intyear_to = 1984
End Select
For i = intyear_from to intyear_to
YearArrList.Add (i)
Next
rptYear.DataSource = YearArrList
rptYear.DataBind ()
'***************************************************************************************
' Temporary DB stuff to move to ReportClass
Dim connection As OracleConnection = New
OracleConnection(ConfigurationSettings.AppSettings("connectionstring"))
connection.Open()
'***************************************************************************************
'Get the provinces into the Arraylist
Dim rdrstoredParams(0) As OracleParameter
rdrstoredParams(0) = New OracleParameter("provcur",
OracleDbType.RefCursor, ParameterDirection.Output)
rdrstoredParams(0).Value = "provcur"
Dim provrdr As OracleDataReader =
OracleHelperV2.ExecuteReader(connection, CommandType.StoredProcedure,
"REPORT_MW_GETPROVS_pkg.GETPROVS",rdrstoredParams)
While provrdr.Read
ProvArrList.Add (provrdr("province_id"))
If (Session("Language") Is "en-CA") Then
ProvNameList.Add (provrdr("english_name"))
Else
ProvNameList.Add (provrdr("french_name"))
End If
End While
ProvArrList.Insert (0,"1")
If (Session("Language") Is "en-CA") Then
ProvNameList.Insert (0,"Federal")
Else
ProvNameList.Insert (0,"Fédéral")
End If
dljurList.DataSource = ProvNameList
dljurList.DataBind ()
Dim storedParams(2) As OracleParameter
storedParams(0) = New OracleParameter("datefrom",
OracleDbType.Varchar2, ParameterDirection.Input)
storedParams(0).Value = stryear_from
storedParams(1) = New OracleParameter("dateto",
OracleDbType.Varchar2, ParameterDirection.Input)
storedParams(1).Value = stryear_to
storedParams(2) = New OracleParameter("hourly_cursor",
OracleDbType.RefCursor, ParameterDirection.Output)
storedParams(2).Value = "hourly_cursor"
Dim rdr As OracleDataReader =
OracleHelperV2.ExecuteReader(connection, CommandType.StoredProcedure,
"REPORT_MW_HOURLYADULT_pkg.GET_HOURLY_DATA",storedParams)
Dim dset As Dataset =
OracleHelperV2.ExecuteDataset(connection, CommandType.StoredProcedure,
"REPORT_MW_HOURLYADULT_pkg.GET_HOURLY_DATA",storedParams)
Dim x As String
Dim y As Integer
Dim n As String
For Each y in ProvArrList
For Each x in YearArrList
n = (x + 1)
n = "1/1/" & n
x = "1/1/" & x
Dim filterstatement As New StringBuilder
filterstatement.append ("effective_date >
#").Append(x).Append("#").Append("And effective_date <
#").Append(n).Append("#").Append("AND prov_prov_id = ").Append(y)
Dim Row As DataRow
Dim Filter As String = (filterstatement.ToString())
Dim MatchRows() As DataRow = dset.Tables("Table").Select(Filter)
For Each Row In MatchRows
Response.Write("<tr><td>" & Row("effective_date").ToString() & "<br>" &
Row("minimum_wage_amount")& "<br>" & " " & Row("prov_prov_id") &
"</td></tr>")
dlwagelist.DataSource = Row
dlwagelist.DataBind ()
next
'rptwageinfo.DataBind()
Next
Next
End Sub
End Class
End NameSpace
tia
dave
have more than 1 record, I have been wrestling with the best solution
for this.
I need data in this fashion:
rowheader col1 col2 col3 col4
row1 data data data data
data data
data
row2 data data data
I am migrating an existing app so if you really want to see how I need
to output the data:
http://206.191.16.142/psait_spila/lmnec_eslc/eslc/salaire_minwage/report2/report2_e.cfm
I have loaded my jurisdiction column into a repeater and the years into
a datalist so I have my shell.
<table cellSpacing=0 cellPadding=0 width="90%" border=1>
<tr>
<th>Jurisdiction </th><asp:repeater id=rptYear runat="server">
<itemtemplate >
<th>
<%# Container.DataItem %>
</th>
</itemtemplate>
</asp:repeater></tr><asp:datalist id=dljurList runat="server"
cellpadding="0" cellspacing="0">
<itemtemplate>
<tr>
<td>
<%# Container.DataItem %>
</td>
<td>
<!--some control to outpu data properly here
-->
</td>
</tr>
</itemtemplate>
</asp:datalist>
</table>
But I need help on how to get my data into the table, I have used
looping constructs to get my data ordered in the proper fashion but
databinding the row does not work...
Object reference not set to an instance of an object.
I'm trying to fill a repeater or datalist when the year matches the
jursidiction, plus I have nulls, plus I have multiple records for some
years. My oop skills are weak so I have been trying to do this in a
procedural fashion.. and it aint workin .. any oop experts that can
show me the way, any help would be appreciated..
My code behind:
Public Class report2
Inherits System.Web.UI.UserControl
Protected rm As ResourceManager
Private yearparam As Integer =
httpContext.Current.Request.QueryString("dec")
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
'Setup the proper decade parameters
Dim YearArrList As New ArrayList (10)
'Setup the prov list for looping through later
Dim ProvArrList As New ArrayList
Dim ProvNameList As New ArrayList
Dim DBDataView As DataView
Dim stryear_from As String
Dim stryear_to As String
Dim intyear_from As String
Dim intyear_to As String
Dim i as Integer
Select Case yearparam
Case 1
'Declare strings to pass as db params
stryear_from = "1965/01/01"
stryear_to = "1974/12/31"
'Declare strings for array params
intyear_from = "1965"
intyear_to = "1974"
Case 2
stryear_from = "1975/01/01"
stryear_to = "1984/12/31"
intyear_from = 1975
intyear_to = 1984
End Select
For i = intyear_from to intyear_to
YearArrList.Add (i)
Next
rptYear.DataSource = YearArrList
rptYear.DataBind ()
'***************************************************************************************
' Temporary DB stuff to move to ReportClass
Dim connection As OracleConnection = New
OracleConnection(ConfigurationSettings.AppSettings("connectionstring"))
connection.Open()
'***************************************************************************************
'Get the provinces into the Arraylist
Dim rdrstoredParams(0) As OracleParameter
rdrstoredParams(0) = New OracleParameter("provcur",
OracleDbType.RefCursor, ParameterDirection.Output)
rdrstoredParams(0).Value = "provcur"
Dim provrdr As OracleDataReader =
OracleHelperV2.ExecuteReader(connection, CommandType.StoredProcedure,
"REPORT_MW_GETPROVS_pkg.GETPROVS",rdrstoredParams)
While provrdr.Read
ProvArrList.Add (provrdr("province_id"))
If (Session("Language") Is "en-CA") Then
ProvNameList.Add (provrdr("english_name"))
Else
ProvNameList.Add (provrdr("french_name"))
End If
End While
ProvArrList.Insert (0,"1")
If (Session("Language") Is "en-CA") Then
ProvNameList.Insert (0,"Federal")
Else
ProvNameList.Insert (0,"Fédéral")
End If
dljurList.DataSource = ProvNameList
dljurList.DataBind ()
Dim storedParams(2) As OracleParameter
storedParams(0) = New OracleParameter("datefrom",
OracleDbType.Varchar2, ParameterDirection.Input)
storedParams(0).Value = stryear_from
storedParams(1) = New OracleParameter("dateto",
OracleDbType.Varchar2, ParameterDirection.Input)
storedParams(1).Value = stryear_to
storedParams(2) = New OracleParameter("hourly_cursor",
OracleDbType.RefCursor, ParameterDirection.Output)
storedParams(2).Value = "hourly_cursor"
Dim rdr As OracleDataReader =
OracleHelperV2.ExecuteReader(connection, CommandType.StoredProcedure,
"REPORT_MW_HOURLYADULT_pkg.GET_HOURLY_DATA",storedParams)
Dim dset As Dataset =
OracleHelperV2.ExecuteDataset(connection, CommandType.StoredProcedure,
"REPORT_MW_HOURLYADULT_pkg.GET_HOURLY_DATA",storedParams)
Dim x As String
Dim y As Integer
Dim n As String
For Each y in ProvArrList
For Each x in YearArrList
n = (x + 1)
n = "1/1/" & n
x = "1/1/" & x
Dim filterstatement As New StringBuilder
filterstatement.append ("effective_date >
#").Append(x).Append("#").Append("And effective_date <
#").Append(n).Append("#").Append("AND prov_prov_id = ").Append(y)
Dim Row As DataRow
Dim Filter As String = (filterstatement.ToString())
Dim MatchRows() As DataRow = dset.Tables("Table").Select(Filter)
For Each Row In MatchRows
Response.Write("<tr><td>" & Row("effective_date").ToString() & "<br>" &
Row("minimum_wage_amount")& "<br>" & " " & Row("prov_prov_id") &
"</td></tr>")
dlwagelist.DataSource = Row
dlwagelist.DataBind ()
next
'rptwageinfo.DataBind()
Next
Next
End Sub
End Class
End NameSpace
tia
dave