Array looping order issue - asp.net

Hey all i am trying to get my array in the correct format to be placed into an ASP.net webpage for a table for an order.
The order should be:
model_number
comm_category
service
freight
sales_tax
sales
unit_price
price
id_price
Currently it is outputting as this:
model_number
price
unit_price
id_price
sales_tax
sales
service
freight
comm_category
And because of this i am unable to append to my string in the correct order using my code here:
Public Sub AssocArray_To_String(ByRef Output As System.Text.StringBuilder, ByVal AssocArrayInput As AssocArray)
For iParent As Integer = 0 To AssocArrayInput.Count - 1
Dim intX As Integer = 0
Dim arrParent As AssocArray = TryCast(AssocArrayInput.Item(iParent), AssocArray)
If arrParent Is Nothing Then Continue For
For iChild As Integer = 0 To arrParent.Count - 1
Call buildItems(PHPConvert.ToString(arrParent.Keys(iChild)), PHPConvert.ToString(arrParent.Values(iChild)), intX)
intX += 1
Next iChild
Next iParent
End Sub
Private Sub buildItems(ByVal nameOfItem As String, ByVal itemItself As String, ByVal intX As Integer)
Dim tmpStuff As Decimal = 0.0
Dim qty As Integer = 1
Dim model_number As String = ""
Dim comm_category As String = ""
Dim service As Double = 0
Dim freight As Double = 0
Dim sales_tax As Double = 0
Dim sales As Double = 0
Dim unit_price As Double = 0
Dim price As Double = 0
Dim id_price As Double = 0
If nameOfItem = "model_number" Then
model_number = itemItself
tableLoop += "<tr><td bgcolor=""#CCCCCC""><asp:Label ID=""item_count_" & intX & """ Text=""Label"">" & qty & "</asp:Label></td>"
tableLoop += "<td bgcolor=""#CCCCCC""><asp:Label ID=""model_number_" & intX & """ Text=""Label"">" & model_number & "</asp:Label></td>"
ElseIf nameOfItem = "comm_category" Then
comm_category = itemItself
tableLoop += "<td bgcolor=""#CCCCCC""><asp:Label ID=""comm_category_" & intX & """ Text=""Label"">" & comm_category & "</asp:Label></td>"
ElseIf nameOfItem = "service" Then
service = Format(Convert.ToDouble(itemItself), "$######.00")
tableLoop += "<td bgcolor=""#CCCCCC""><asp:Label ID=""service_" & intX & """ Text=""Label"">" & service & "</asp:Label></td>"
ElseIf nameOfItem = "freight" Then
freight = Format(Convert.ToDouble(itemItself), "$######.00")
tableLoop += "<td><asp:Label ID=""freight_" & intX & """ Text=""Label"">" & freight & "</asp:Label></td>"
ElseIf nameOfItem = "sales_tax" Then
sales_tax = Format(Convert.ToDouble(itemItself), "$######.00")
tableLoop += "<td><asp:Label ID=""sales_tax_" & intX & """ Text=""Label"">" & sales_tax & "</asp:Label></td>"
ElseIf nameOfItem = "sales" Then
sales = Format(Convert.ToDouble(itemItself), "$######.00")
tableLoop += "<td bgcolor=""#CCCCCC""><asp:Label ID=""sales_" & intX & """ Text=""Label"">" & sales & "</asp:Label></td>"
ElseIf nameOfItem = "unit_price" Then
unit_price = Format(Convert.ToDouble(itemItself), "$######.00")
tableLoop += "<td bgcolor=""#CCCCCC""><asp:Label ID=""unit_price_" & intX & """ Text=""Label"">" & unit_price & "</asp:Label></td></tr>"
ElseIf nameOfItem = "price" Then
price = Format(Convert.ToDouble(itemItself), "$######.00")
tableLoop += "<td><asp:Label ID=""amount_" & intX & """ Text=""Label"">" & price & "</asp:Label></td>"
ElseIf nameOfItem = "id_price" Then
id_price = Format(Convert.ToDouble(itemItself), "$######.00")
tableLoop += "<td><asp:Label ID=""id_price_" & intX & """ Text=""Label"">" & id_price & "</asp:Label></td>"
End If
End Sub
The end results are this:
<tr><td bgcolor="#CCCCCC"><asp:Label ID="item_count_0" Text="Label">1</asp:Label></td>
<td bgcolor="#CCCCCC"><asp:Label ID="model_number_0" Text="Label">TTN491-7BW</asp:Label></td>
<td bgcolor="#CCCCCC"><asp:Label ID="sales_1" Text="Label">3084.63</asp:Label></td>
<td><asp:Label ID="amount_2" Text="Label">3810</asp:Label></td>
<td><asp:Label ID="sales_tax_3" Text="Label">290.37</asp:Label></td>
<td><asp:Label ID="id_price_4" Text="Label">3810</asp:Label></td></tr>
<td bgcolor="#CCCCCC"><asp:Label ID="comm_category_5" Text="Label">X24</asp:Label></td>
<td bgcolor="#CCCCCC"><asp:Label ID="service_6" Text="Label">51</asp:Label></td>
<td><asp:Label ID="freight_7" Text="Label">384</asp:Label></td>
<td bgcolor="#CCCCCC"><asp:Label ID="unit_price_8" Text="Label">3135.63</asp:Label></td></tr>
Which should output like this:
<tr><td bgcolor="#CCCCCC"><asp:Label ID="item_count_0" Text="Label">1</asp:Label></td>
<td bgcolor="#CCCCCC"><asp:Label ID="model_number_0" Text="Label">TTN491-7BW</asp:Label></td>
<td bgcolor="#CCCCCC"><asp:Label ID="comm_category_5" Text="Label">X24</asp:Label></td>
<td bgcolor="#CCCCCC"><asp:Label ID="service_6" Text="Label">51</asp:Label></td>
<td><asp:Label ID="freight_7" Text="Label">384</asp:Label></td>
<td><asp:Label ID="sales_tax_3" Text="Label">290.37</asp:Label></td>
<td bgcolor="#CCCCCC"><asp:Label ID="sales_1" Text="Label">3084.63</asp:Label></td>
<td bgcolor="#CCCCCC"><asp:Label ID="unit_price_8" Text="Label">3135.63</asp:Label></td></tr>
<td><asp:Label ID="amount_2" Text="Label">3810</asp:Label></td>
<td><asp:Label ID="id_price_4" Text="Label">3810</asp:Label></td></tr>
How can i put the array in the correct order?

Why aren't you just simply referencing the items you need directly, instead of looping through the associative keys (which come back in arbitrary order):
Dim arrParent As AssocArray = TryCast(AssocArrayInput.Item(iParent), AssocArray)
If arrParent Is Nothing Then Continue For
Call buildItems("model_number", PHPConvert.ToString(arrParent.Values("model_number")), intX)
Call buildItems("comm_category", PHPConvert.ToString(arrParent.Values("model_number")), intX)
Call buildItems("service", PHPConvert.ToString(arrParent.Values("model_number")), intX)
Call buildItems("freight", PHPConvert.ToString(arrParent.Values("model_number")), intX)
'ETC
Or better yet, just get rid of BuildItems altogether and inline the logic in the appropriate places above.

You are calling
For iChild As Integer = 0 To arrParent.Count - 1
Call buildItems(PHPConvert.ToString(arrParent.Keys(iChild)),
PHPConvert.ToString(arrParent.Values(iChild)),
intX)
intX += 1
Next iChild
Therefor you will always get the order of the items in arrParent. So all you have to do ist call buildItems(...) manually in the correct order
Call buildItems(PHPConvert.ToString("model_number"),
PHPConvert.ToString(arrParent.Values("model_number")),
intX)
Call buildItems(PHPConvert.ToString("comm_category"),
PHPConvert.ToString(arrParent.Values("comm_category")),
intX)
' and so on
Furthermore I can't find a definition for tableLoop in buildItems. It seems that this is a simple string variable. You should make use of a StringBuilder as this class is way faster in concatenating strings! See MSDN.

Related

How to reuse an array in asp.net vb

I'm having to build a table of web pages and languages, i.e. page 1: en it de in a schema where there could be up to 14 languages. The page contents are held in a database. So to build the table I'm doing the following:
Dim rowArrayList As New ArrayList
Dim thisRow(languageNum) As String 'languageNum equates to number of columns -1
Database access then:
'# Create row array of cell arrays
If pageName <> lastPageName Then
lastPageName = pageName
If j >= languageNum Then
rowArrayList.Add(thisRow)
Array.Clear(thisRow, 0, thisRow.Length)
j = 0
End If
thisRow(0) = "<td class=""pageName"">" & pageName & "</td>"
End If
'# Iterate each cell in the row
For i As Integer = 1 To languageNum - 1
If thisRow(i) = "" Then
If transReady = False And active = False Then
thisRow(i) = "<td class=""trans"">" & langISO & "</td>"
ElseIf transReady = True And active = False Then
thisRow(i) = "<td class=""notActive"">" & langISO & "</td>"
ElseIf transReady = True And active = True And i = thisLangID Then
thisRow(i) = "<td class=""active"">" & langISO & "</td>"
End If
End If
j = j + 1
Next
The build the table:
'# Build output table
For Each row As String() In rowArrayList
tableBody.Text += "<tr>"
For Each cell As String In row
If cell = "" Then
tableBody.Text += "<td class=""notTrans""> </td>"
Else
tableBody.Text += cell
End If
Next
tableBody.Text += "</tr>"
Next
The table displays beautifully BUT every row contains the data for what should be the last row. How can it be fixed it so each thisRow is unique in the the rowArrayList? At the moment, every time thisRow is added to rowArrayList, every rowArrayList index is overwritten, not just the one being added.
For the quick fix, instead of this:
Array.Clear(thisRow, 0, thisRow.Length)
Do this:
thisRow = New String(languageNum) {}
or this:
ReDim thisRow(languageNum)
However, I suspect there are some simple design choices you could change that would drastically change this code for the better.

CLASSIC ASP PAGINATION

I use this code to show pagination of recordset in classic asp + Mysql:
<ul class="pagination">
<% IF Cint(PageNo) > 1 then %>
<li><a rel="1" href="#" data-topic="<%=Request.QueryString("TOPIC_ID")%>" data-page="1">Prime</a></li>
<li><a rel="<%=PageNo-1%>" href="#" data-topic="<%=Request.QueryString("TOPIC_ID")%>" data-page="<%=PageNo-1%>"><</a></li>
<% End IF%>
<% For intID=1 To TotalPage%>
<% if intID=Cint(PageNo) Then%>
<li><%=intID%></li>
<%Else%>
<li><a rel="<%=intID%>" href="#" data-topic="<%=Request.QueryString("TOPIC_ID")%>" data-page="<%=intID%>"><%=intID%></a></li>
<%End IF%>
<%Next%>
<% IF Cint(PageNo) < TotalPage Then %>
<li><a rel="<%=PageNo+1%>" href="#" data-topic="<%=Request.QueryString("TOPIC_ID")%>" data-page="<%=PageNo+1%>">></a></li>
<li><a rel="<%=TotalPage%>" href="#" data-topic="<%=Request.QueryString("TOPIC_ID")%>" data-page="<%=TotalPage%>">Ultime</a></li>
<% End IF%>
</ul>
But If I have a lot of pageresults, it show a long line of number.... How could show only 5 page an when change page, show next?
like so:
first < 1 2 3 4 5 > last
and if I click on 5
first < 5 6 7 8 9 > last
etc...
This code works also if you want to keep some other querystring parameters. It removes the page value, adds the new page value and builds the paging control html.
It uses the Twitter Bootstrap Styles: http://twitter.github.io/bootstrap/components.html#pagination
Usage:
Response.Write PagingControl(10, 30, "?field-keywords=whatever&page=7")
Code:
Public Function RemoveEmptyQueryStringParameters(strQueryString)
If IsNullOrEmpty(strQueryString) Then Exit Function
Dim strNewQueryString: strNewQueryString = ""
strQueryString = Replace(strQueryString, "&", "&")
strQueryString = Replace(strQueryString, "?", "&")
Dim arrQueryString: arrQueryString = Split(strQueryString ,"&")
For i=0 To UBound(arrQueryString)
strTempParameter = Left( arrQueryString(i), Instr( arrQueryString(i) & "=", "=" ) - 1 )
strTempParameterValue = Right( arrQueryString(i), Len( arrQueryString(i) ) - InstrRev( arrQueryString(i), "=" ) )
If Not IsNullOrEmpty(strTempParameterValue) Then
strNewQueryString = strNewQueryString & "&" & arrQueryString(i)
End If
Next
If InStr(strNewQueryString,"&") = 1 Then
strNewQueryString = "?" & Right(strNewQueryString, Len(strNewQueryString) - 1)
End If
strNewQueryString = Replace(strNewQueryString, "&", "&")
Erase arrQueryString
Set arrQueryString = Nothing
RemoveEmptyQueryStringParameters = Trim(strNewQueryString)
End Function
Public Function AddQueryStringParameter(ByVal strQueryString, ByVal strParameter, ByVal strValue)
Dim strNewQueryString: strNewQueryString = ""
strNewQueryString = Replace(strQueryString, "&", "&")
strNewQueryString = Replace(strNewQueryString, "?", "&")
strNewQueryString = strNewQueryString & "&" & strParameter & "=" & strValue
If InStr(strNewQueryString,"&") = 1 Then
strNewQueryString = "?" & Right(strNewQueryString, Len(strNewQueryString) - 1)
End If
strNewQueryString = Replace(strNewQueryString, "&", "&")
AddQueryStringParameter = Trim(strNewQueryString)
End Function
Public Function PagingControl(ByVal intPage, ByVal intPageCount, ByVal strQueryString)
If intPageCount <= 1 Then
PagingControl = ""
Exit Function
End If
strQueryString = RemoveEmptyQueryStringParameters(strQueryString)
strQueryString = RemoveQueryStringParameter(strQueryString, "page")
Dim strQueryStringPaging: strQueryStringPaging = ""
Dim strHtml: strHtml = "<div class=""pagination""><ul>"
If cInt(intPage) > 1 Then
strQueryStringPaging = AddQueryStringParameter(strQueryString, "page", "1")
strHtml = strHtml & "<li>Anfang</li>"
strQueryStringPaging = AddQueryStringParameter(strQueryString, "page", CInt(intPage - 1))
strHtml = strHtml & "<li>< Zurück</li>"
Else
strHtml = strHtml & "<li class=""disabled"">Anfang</li>" & _
"<li class=""disabled"">< Zurück</li>"
End If
Dim intPagesToShow: intPagesToShow = 10
If intPageCount >= intPagesToShow Then
If Cint(intPage)>Int(intPagesToShow/2) Then
If Cint(intPage)>(intPageCount-Int(intPagesToShow/2)) Then
intStart = intPageCount-intPagesToShow
intEnd = intPageCount
Else
intStart = intPage-Int(intPagesToShow/2)
intEnd = intPage+Int(intPagesToShow/2)
End If
Else
intStart = 1
intEnd = intPagesToShow
End If
Else
intStart=1
intEnd=intPageCount
End If
If intStart=0 Then
intStart=1
End If
For i = intStart To intEnd
If Cint(intPage)=i Then
strHtml = strHtml & "<li class=""active"">" & i & "</li>"
Else
strQueryStringPaging = AddQueryStringParameter(strQueryString, "page", Cint(i))
strHtml = strHtml & "<li>" & i & "</li>"
End If
Next
If cInt(intPage) < cInt(intPageCount) Then
strQueryStringPaging = AddQueryStringParameter(strQueryString, "page", CInt(intPage + 1))
strHtml = strHtml & "<li>Vorwärts ></li>"
strQueryStringPaging = AddQueryStringParameter(strQueryString, "page", Cint(intPageCount))
strHtml = strHtml & "<li>Ende</li>"
Else
strHtml = strHtml & "<li class=""disabled"">Vorwärts ></li>" & _
"<li class=""disabled end"">Ende</li>"
End If
strHtml = strHtml & "</ul></div>"
PagingControl = Trim(strHtml)
End Function
I needed a simular solution in ASP.
I could not find anything usefull, so I made something myself.
I normally only program in PHP, but that wasn't possible in the case where I made this.
So if my code is a bit slopy, feel free to improve ;)
A little function I cooked up:
<%
page = cInt(Request.QueryString("pg"))
pages = cInt(number of pages)
if page <1 then page = 1
if page > pages then page = pages
Function paginationHTML(page, lastPage, URL)
if page >1 then
paginationHTML = "prev"
paginationHTML = paginationHTML & "1"
end if
if page >2 then
paginationHTML = paginationHTML & "<a>...</a>"
end if
if page >0 then
paginationHTML = paginationHTML & "<a href=""" & URL & page & """ class='jp-current'>"& page &"</a>"
end if
if lastPage >2 then
if page < lastPage-1 then
paginationHTML = paginationHTML & "<a>...</a>"
end if
end if
if page < lastPage then
paginationHTML = paginationHTML & ""&lastPage&""
paginationHTML = paginationHTML & "next"
end if
End Function
%>
use like so:
<%=paginationHTML(page,pages,"?pg=")%>

Same data is displayed multiple times. Why?

I have an Active Server Page, which displays Bookings of the current Day in a HTML- Table. I display informations like Roomname, Organizer, From, To and Participants.
My Problem is that if i try to get the Participants from a booking, the Participants for a specific booking is displayed in multiple booking even if it does not belong to that booking.
To illustrate my Problem:
DailyPlan
As you can see the Name of the Participants "Kashif Butt" or "adad" is displayed multiple times. But they only belongs to the Booking with the name "PASS"
What could be the Problem? I searched for hours but did not found the Problem. Hope you can help me.
My Code so far:
<%
Dim connection, recordset, sSQL, sConnString, next10, prev10, P
Dim thema, rsRaum, raum_id, KOPPELBESTUHLUNG_ID, raumname, pageCount
Dim TeilnehmerNameExtern, TeilnehmerFirmaExtern
Dim CurrentDate
CurrentDate = Now()
Dim intHour
Dim intMinute
Dim intSecond
intHour = 17
intMinute = 0
intSecond = 0
Dim Time
Time = TimeSerial(intHour, intMinute, intSecond)
Dim Timeda
Timeda = Date()
Dim ts2
ts2 = Timeda + Time
Dim DayOfWeek
DayOfWeek = weekday(CurrentDate)
If CurrentDate < ts2 Then
If DayOfWeek = Weekday(7) Then
CurrentDate = DateAdd("d",2,CurrentDate)
End If
If DayOfWeek = Weekday(1) Then
CurrentDate = DateAdd("d",1,CurrentDate)
End If
If DayOfWeek = Weekday(2) or DayOfWeek = Weekday(3) or DayOfWeek = Weekday(4) or DayOfWeek = Weekday(5) or DayOfWeek = Weekday(6) Then
CurrentDate = CurrentDate
End If
Else If CurrentDate > ts2 Then
If DayOfWeek = Weekday(7) Then
CurrentDate = DateAdd("d",2,CurrentDate)
End If
If DayOfWeek = Weekday(1) Then
CurrentDate = DateAdd("d",1,CurrentDate)
End If
If DayOfWeek = Weekday(2) or DayOfWeek = Weekday(3) or DayOfWeek = Weekday(4) or DayOfWeek = Weekday(5)Then
CurrentDate = DateAdd("d",1,CurrentDate)
End If
If DayOfWeek = Weekday(6) Then
CurrentDate = DateAdd("d",3,CurrentDate)
End If
End If
End If
Set Connection = Server.CreateObject("ADODB.Connection")
Set Recordset = Server.CreateObject("ADODB.Recordset")
Set rsRaum = Server.CreateObject("ADODB.Recordset")
sConnString = "Driver={SQL Server}; Server=localhost; Database=fifa;"
sSQL="select distinct THEMA, ID, AGENDA, VON, BIS, PERSONENZAHL, THEMA_ENABLED from VIEW_RAUMBUCHUNG_DISPO " & _
"where von >= convert(date, getdate(), 4) " & _
" and von < convert(date, dateadd(day,1, GETDATE()), 4) " & _
" and BIS >= getdate() " & _
" and STORNO is null " & _
" order by von, bis"
Connection.Open sConnString
Recordset.open sSQL, sConnString,1,1
%>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<meta http-equiv="REFRESH" content="10"/>
<style type="text/css" media="all">
body{font-family: Arial;}
h4{font-size: 10pt;font-weight: bold;white-space: nowrap;margin-top: 0; margin-bottom: 10px;}
th{font-size: 9pt;font-weight: normal;text-align: center;white-space: nowrap;}
td{font-size: 9pt;}.content
td{border: solid 1px #dadada;}.content
th{border: solid 1px #dadada;background-image: url("tbl_header_row_bg.gif"); background-repeat: repeat-x; white-space: nowrap;}
</style>
</head>
<form name=form1>
<p align="left" style="margin-top:20px;margin-bottom:20px;font-family:'Arial';font-size:20pt; color:#000000"> Daily Plan </p>
<p align="left" style="margin-top:10px;margin-bottom:20px;font-family:'Arial';font-size:10pt; color:
font-weight:bold;color:#000000"><% =formatDateTime(CurrentDate, 1)%>
</p>
</form>
<table width="100%" class="content" cellpadding="3" cellspacing="0" border="0" style="border-collapse: collapse;">
<tr>
<th width="350" align="left">Event</th>
<th width="100" align="absmiddle">Room</th>
<th width="60" align="absmiddle">From</th>
<th width="60" align="absmiddle">To</th>
<th align="left">Equipment</th>
<th align="left">Catering</th>
<th align="left">Agenda</th>
<th align="left">Participants</th>
<th align="absmiddle">Persons</th>
</tr>
<%
'If Recordset.EoF Then
'Response.write "No records to display"
Do Until Recordset.Eof
rsRaum.open "select raum_id, KOPPELBESTUHLUNG_ID from RESERVIERUNGRAUM where buchung_id = " & Recordset("ID"), Connection
raum_id = rsRaum("raum_id")
KOPPELBESTUHLUNG_ID = rsRaum("KOPPELBESTUHLUNG_ID")
rsRaum.close
' falls Kopplung, hole ID des "Parent"-Raumes
if not isNull( KOPPELBESTUHLUNG_ID ) then
rsRaum.open "select parent_id from KOPPELN where CHILD_ID = " & raum_id, Connection
if not rsRaum.EOF then
raum_id = rsRaum("parent_id")
end if
rsRaum.close
end if
'Hole Teilnehmer
' hole Raum Details
rsRaum.open "select bezeichnung from Raum where ID = " & raum_id, Connection
raumname = rsRaum("bezeichnung")
rsRaum.close
rsRaum.open "SELECT DISTINCT NAME, FIRMA FROM TEILNEHMER WHERE buchung_id = " & Recordset("ID") & " and STATUS = 2 and DAILYPLAN = 1" , Connection
if not rsRaum.EOF then
dim new_list
new_list = ""
do while not rsRaum.eof
new_list = new_list & rsRaum("NAME") & " " & "(" & rsRaum("FIRMA") & ")" & ","
rsRaum.movenext
loop
new_list = left(new_list, len(new_list)-1)
end if
rsRaum.close
rsRaum.open "SELECT DISTINCT TRIGRAM FROM TEILNEHMER WHERE buchung_id = " & Recordset("ID") & " and STATUS = 1 and DAILYPLAN = 1" , Connection
Response.Write(rsRaum.recordcount)
if not rsRaum.EOF then
dim new_list2
new_list2 = ""
do while not rsRaum.eof
new_list2 = new_list2 & rsRaum("TRIGRAM") & ","
rsRaum.movenext
loop
new_list2 = left(new_list2, len(new_list2)-1)
end if
rsRaum.close
rsRaum.Open "SELECT distinct d.Bezeichnung, rd.Bestellmenge " & _
"FROM RESERVIERUNGDIENSTLEISTUNG rd " & _
"JOIN DIENSTLEISTUNG d ON rd.DIENSTLEISTUNG_ID = d.ID " & _
"JOIN RESERVIERUNGRAUM rr ON rd.RESERVIERUNGRAUM_ID = rr.ID " & _
"JOIN DIENSTLEISTUNGSART dlart ON d.DIENSTLEISTUNGSART_ID = dlart.ID " & _
"JOIN ABRECHNUNGSGRUPPE ab ON dlart.ABRECHNUNGSGRUPPE_ID = 3 " & _
"JOIN BUCHUNG b ON rr.BUCHUNG_ID = " & Recordset("ID"), Connection
if not rsRaum.EOF then
dim new_list3
new_list3 = ""
do while not rsRaum.eof
new_list3 = new_list3 & rsRaum("Bezeichnung") & ","
rsRaum.movenext
loop
new_list3 = left(new_list3, len(new_list3)-1)
end if
rsRaum.close
if ucase( Recordset("thema_enabled") ) = "Y" or isnull(Recordset("thema_enabled")) then
thema = Recordset("THEMA")
else
thema = ""
end if
%>
<tr "margin-bottom:100px" height="30" valign="top">
<td style="overflow:hidden;"><% =thema %></td>
<td align="center"; ><% =raumname %><br></td>
<td align="center"; ><% =FormatDateTime( Recordset("von"), 4)%></td>
<td align="center"; ><% =FormatDateTime( Recordset("bis"), 4) %></td>
<td align="center"; ><br></td>
<td align="center"; ><% =new_list3 %><br></td>
<td align="center"; ><% =Recordset("agenda") %></td>
<td ><% =new_list%><br><% =new_list2%><br></td>
<td align="center"; ><% =Recordset("personenzahl") %><br></td>
</tr>
<%
Recordset.MoveNext
Loop
'End If
Recordset.Close
Set Recordset = Nothing
Connection.Close
Set Recordset = Nothing
%>
</table>
</body>
</html>
The problem is that the values of new_list and new_list2 are not cleared in each iteration

How show colors in export to excel in asp.net

iam doing export functionality in asp.net1.1....
I want to highlight some records in red color when i export to excel...
following is my code to export records in excel but i want some records in red colors...
So how to do this plz help me out.
Public Shared Sub ExportToExcelInvitee(ByVal query As String, _
ByRef Response As System.Web.HttpResponse, _
Optional ByVal exportDataset As DataSet = Nothing)
Dim index As Integer
Dim colIndex As Integer
Dim columnCount As Integer
Dim excelDataSet As DataSet
Dim cnt As Integer
Const PROC As String = CLASSNAME & ".ExportToExcelInvitee"
Try
If IsNothing(exportDataset) Then
excelDataSet = ExecuteDataset(query)
Else
excelDataSet = exportDataset
End If
If Not IsNothing(excelDataSet) Then
If excelDataSet.Tables(0).Rows.Count <> 0 Then
Response.Clear()
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Response.AddHeader("Content-Disposition", "attachment; filename=List.xls")
Response.Write("<TABLE border=1>")
Response.Write("<TR>")
Response.Write("<TD><DIV align=center><B>Sr. No.</B></DIV></TD>")
columnCount = excelDataSet.Tables(0).Columns.Count - 1
For index = 2 To columnCount
Response.Write("<TD>" & _
"<DIV align=center>" + _
"<B>" & excelDataSet.Tables(0).Columns(index).ColumnName.ToString & "</B>" + _
"</DIV>" & _
"</TD>")
Next
Response.Write("</TR>")
Response.Write("<TR>")
' Loop to leave one empty line after header,
' Loopimg to add the TD with black boders which doens not get added if only TR added
For index = 2 To columnCount
Response.Write("<TD></TD>")
Next
Response.Write("</TR>")
cnt = 1
For index = 0 To excelDataSet.Tables(0).Rows.Count - 1
If Not (excelDataSet.Tables(0).Rows(index).RowState = DataRowState.Deleted) Then
Response.Write("<TR>")
Response.Write("<TD>" & _
"<DIV align=left>" & _
(cnt).ToString() & _
"</DIV>" & _
"</TD>")
For colIndex = 2 To columnCount
Response.Write("<TD valign=top>" & _
"<DIV align=left>" & _
excelDataSet.Tables(0).Rows(index).Item(colIndex).ToString() & _
"</DIV>" & _
"</TD>")
Next
Response.Write("</TR>")
cnt = cnt + 1
End If
Next
Response.Write("</TABLE>")
Response.End()
End If 'DataSet must contain data
End If 'DataSet must contain data
Catch ex As Exception
Call ErrorLog(PROC & ", " & ex.Source, ex.Message)
End Try
End Sub
In your case, that would be simply:
<TD style='color: red'>Some value</TD>
I can't see where you decide which cells should be highlighted red - however, since you're basically outputting an html table, you should be able to use standard markup to change either the 'color' or 'backgroundColor' attribute for that html element.

asp pagination problem

Hi i have a problem with this asp pagination. it seems to be putting all the links in the one row, so i think it might have something to do with the check of the int i...
but im not that familar with asp. can anyone shed any light on this problem.
the folders contain pdfs for each day of the month, named A08P2.pdf A09P2.pdf etc...
Thanks
i = 1
Set fc = f.Files
Set ff = f.SubFolders
For Each f1 in fc
intPage = cint(mid(f1.name,2,2))
chrEdition = mid(f1.name,1,1)
if chrEdition = "A" then
if i = 1 then
Response.Write "<tr>"
end if
Response.Write "<td width='40' align='center'><a href=" & sUP & f1.name & " class='blue_11px'>" & intPage & "</a></td>"
if i = 10 then
Response.Write "</tr>"
i = 0
end if
end if
i = i + 1
Next
You should move the incrementing of the i (i=i+1) inside the if...end if, since if i is 9 and you encounter two chrEditions that are not 'A' then i will become 11 and will never match the closing condition i=10:
if chrEdition = "A" then
if i = 1 then
Response.Write "<tr>"
end if
Response.Write "<td width='40' align='center'><a href=" & sUP & f1.name & " class='blue_11px'>" & intPage & "</a></td>"
if i = 10 then
Response.Write "</tr>"
i = 0
end if
i = i + 1
end if

Resources