multirecord grid cells - how??

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
 
G

Guest

One time use: Output into a table from your code behind.

Multi-use: Create a control (user or server) and encapsulate the
functionality.

While you may be able to "trick" the .NET controls to do what you want, it
is not the wisest means of accomplishing this task. Duct tape only last so
long. If someone asks for more functionality, you may find the duct tape you
set up ripping all over the place. Why not do it right the first time?

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
G

Guest

One more thought:
I recently worked on an application where a DataGrid was used. The
programmer used the Data binding event of the Grid to circumvent binding and
force it to do what he wished. It was an interesting system and I appreciated
the thinking outside of the box. BUT (big but), when it came to extending the
platform, it was a royal pain in the butt. Ultimately, we had to rip it apart
and do it the right way. If the person designing had not simply bolted on
something that worked, we would have had a solid foundation to work from.
Don't do that to those who come up behind you, much less to yourself.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
D

drdave

Thanks for the thoughts... So do you think that a custom control is the
way to go... there is no built in control that can handle my needs is
there??
 
F

Fred

in this project i`m working on currently "dataGridABC.ItemDataBound +="
is all over the place
can u point me to some article showing this is a bad thing to do

TIA
 

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,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top