I have list of object like this one:
+-------------+------------+---------------------+
| ID | Value | Time |
+-------------+------------+---------------------+
| 1 | 1 | 2019-03-07 20:05:35 |
| 2 | 2 | 2019-03-07 20:06:09 |
| 5 | 5 | 2019-03-07 20:11:27 |
| 7 | 1 | 2019-03-07 20:13:30 |
| 8 | 0 | 2019-03-07 20:13:41 |
| 7 | 1 | 2019-03-07 20:17:00 |
| 8 | 0 | 2019-03-07 20:22:20 |
| 7 | 1 | 2019-03-07 20:23:05 |
| 8 | 0 | 2019-03-07 20:27:35 |
| 7 | 1 | 2019-03-07 20:27:37 |
| 8 | 0 | 2019-03-07 20:28:01 |
| 7 | 1 | 2019-03-07 20:37:19 |
| 8 | 0 | 2019-03-07 20:37:27 |
| 7 | 1 | 2019-03-07 20:37:54 |
| 8 | 0 | 2019-03-07 20:40:11 |
| 7 | 1 | 2019-03-07 20:44:00 |
| 8 | 0 | 2019-03-07 20:45:00 |
| 7 | 1 | 2019-03-07 20:47:41 |
| 7 | 1 | 2019-03-07 20:48:43 |
| 7 | 1 | 2019-03-07 20:48:51 |
| 8 | 0 | 2019-03-07 20:51:11 |
| 8 | 0 | 2019-03-07 20:54:46 |
| 8 | 0 | 2019-03-07 20:55:36 |
+-------------+------------+---------------------+
How to select records 15 minutes apart but records that are more close to the next time?
The result should be something like this:
+-------------+------------+---------------------+
| ID | Value | Time |
+-------------+------------+---------------------+
| 1 | 1 | 2019-03-07 20:05:35 |
| 8 | 0 | 2019-03-07 20:22:20 |
| 7 | 1 | 2019-03-07 20:37:19 |
| 8 | 0 | 2019-03-07 20:51:11 |
+-------------+------------+---------------------+
If the first time is 20:05:35 and next apart 15 min is 20:22:20. The closest time to that is 20:22:20 because difference between them is 00:02:14 and between 20:17:35 is difference 00:02:25. Is there any way to calculate difference and make decision which one is closer to choose?
Try following :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace ConsoleApplication132
{
class Program
{
static void Main(string[] args)
{
List<Dates> dates = Dates.GetDates();
var results = dates.GroupBy(x => new DateTime(x.Time.Year, x.Time.Month, x.Time.Day, x.Time.Hour, 15 * (x.Time.Minute / 15), 0).AddMinutes(15))
.Select(x => x.OrderBy(y => x.Key.Subtract(y.Time)).First())
.ToList();
}
}
public class Dates
{
public int ID { get;set;}
public int Value { get;set;}
public DateTime Time { get;set;}
public static List<Dates> GetDates()
{
string input =
"| 1 | 1 | 2019-03-07 20:05:35 |\n" +
"| 2 | 2 | 2019-03-07 20:06:09 |\n" +
"| 5 | 5 | 2019-03-07 20:11:27 |\n" +
"| 7 | 1 | 2019-03-07 20:13:30 |\n" +
"| 8 | 0 | 2019-03-07 20:13:41 |\n" +
"| 7 | 1 | 2019-03-07 20:17:00 |\n" +
"| 8 | 0 | 2019-03-07 20:22:20 |\n" +
"| 7 | 1 | 2019-03-07 20:23:05 |\n" +
"| 8 | 0 | 2019-03-07 20:27:35 |\n" +
"| 7 | 1 | 2019-03-07 20:27:37 |\n" +
"| 8 | 0 | 2019-03-07 20:28:01 |\n" +
"| 7 | 1 | 2019-03-07 20:37:19 |\n" +
"| 8 | 0 | 2019-03-07 20:37:27 |\n" +
"| 7 | 1 | 2019-03-07 20:37:54 |\n" +
"| 8 | 0 | 2019-03-07 20:40:11 |\n" +
"| 7 | 1 | 2019-03-07 20:44:00 |\n" +
"| 8 | 0 | 2019-03-07 20:45:00 |\n" +
"| 7 | 1 | 2019-03-07 20:47:41 |\n" +
"| 7 | 1 | 2019-03-07 20:48:43 |\n" +
"| 7 | 1 | 2019-03-07 20:48:51 |\n" +
"| 8 | 0 | 2019-03-07 20:51:11 |\n" +
"| 8 | 0 | 2019-03-07 20:54:46 |\n" +
"| 8 | 0 | 2019-03-07 20:55:36";
List<Dates> dates = new List<Dates>();
string line = "";
StringReader reader = new StringReader(input);
while ((line = reader.ReadLine()) != null)
{
string[] lineArray = line.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
Dates newDate = new Dates()
{
ID = int.Parse(lineArray[0]),
Value = int.Parse(lineArray[1]),
Time = DateTime.Parse(lineArray[2])
};
dates.Add(newDate);
}
return dates;
}
}
}
The code move the time exactly at the 15 minute interval to next interval. The smallest resolution of time is 100ns (1 tick) so subtract 1 tick I believe is the correct solution
var results = dates.GroupBy(x => new DateTime(x.Time.Year, x.Time.Month, x.Time.Day, x.Time.Hour, 15 * (x.Time.Minute / 15), 0).AddMinutes(15).AddTicks(-1))
.Select(x => x.OrderBy(y => x.Key.Subtract(y.Time)).First())
.ToList();
To group by 15 minutes from start time use this
//tick is 100ns
const long TICKS_PER_15_MINUTES = 15 * 60 * 10000000L; //minutes, seconds, ticks
DateTime minTime = dates.OrderBy(x => x.Time).First().Time;
List<Dates> results = dates.GroupBy(x => (TICKS_PER_15_MINUTES * ((x.Time.Ticks - minTime.Ticks) / TICKS_PER_15_MINUTES) + TICKS_PER_15_MINUTES - 1))
.Select(x => x.OrderBy(y => x.Key - y.Time.Ticks).First())
.ToList();
Finally if you want closest 15 minutes from min time
//tick is 100ns
const long TICKS_PER_15_MINUTES = 15 * 60 * 10000000L; //minutes, seconds, ticks
DateTime minTime = dates.OrderBy(x => x.Time).First().Time;
List<Dates> results = dates.GroupBy(x => ((x.Time.Ticks - minTime.Ticks) % TICKS_PER_15_MINUTES) < (TICKS_PER_15_MINUTES / 2)
? TICKS_PER_15_MINUTES * ((x.Time.Ticks - minTime.Ticks) / TICKS_PER_15_MINUTES)
: (TICKS_PER_15_MINUTES * ((x.Time.Ticks - minTime.Ticks) / TICKS_PER_15_MINUTES)) + TICKS_PER_15_MINUTES)
.Select(x => x.OrderBy(y => Math.Abs( x.Key - y.Time.Ticks)).First())
.ToList();
Related
I am having excel file like following structure:
ColA | ColB | ColC | ColD | ColE | ColF | ColG
1 | a | a | 23 | 12 | asd | 5
2 | s | v | 73 | 14 | qsd | 7
4 | t | b | 52 | 52 | avn |
2 | y | t | 13 | 71 | asx | 2
5 | d | e | 20 | 18 | vss |
1 | f | n | 63 | 72 | ann |
9 | g | a | 27 | 10 | aqz | 15
I want to read and get only those rows which does not have value in ColG.
I can iterate every rows and match each cell value of every row using following code:
for (int i = 0; i < rows.Count(); i++)
{
DataRow dataRow = dataTable.NewRow();
int cellCounter = 0;
foreach (Cell cell in rows.ElementAt(i))
{
dataRow[cellCounter] = GetCellValue(spreadSheetDocument, cell);
cellCounter++;
}
dataTable.Rows.Add(dataRow);
}
But it is very memory and time consuming process.
Can anyone help me out to achieve the same.
Thanks in advance.
i use Linq with DataSet for excel multi sheet.
How to use Group by LINQ?
Sample Data:
Name | Rate | Date | Code | ROW_SEQ
A | 12 | 01/01/2015 | 12 | 1
B | 13 | 01/01/2015 | 12 | 2
Sub Total | 25 | 01/01/2015 | 12 |
C | 10 | 01/01/2015 | 12 | 3
Grand Total | 35 | 01/01/2015 | 12 |
D | 15 | 10/01/2015 | 15 | 1
E | 16 | 10/01/2015 | 15 | 2
Sub Total | 31 | 10/01/2015 | 15 |
F | 10 | 10/01/2015 | 15 | 3
Grand Total | 41 | 10/01/2015 | 15 |
C# Code:
protected void btnExportExcel_Click(object sender, EventArgs e)
{
/*== How to use Group by LINQ? ==*/
DataSet dsTmp = new DataSet();
DataTable dtTmp = dtExport.Copy();
var grouped = from table in dtTmp.AsEnumerable()
group table by new { date_Col = table["date"] , code_Col = table["code"] } into groupby
select new
{
Value = groupby.Key,
ColumnValues = groupby
};
/*== How to use Group by LINQ? ==*/
foreach (var key in grouped)
{
dtTmp = new DataTable();
dtTmp = dtExport.Clone();
dtTmp.TableName = (key.Value.settle_date_Col + "-" + key.Value.bank_code_Col).Replace("00:00:00", "").Replace("/","");
foreach (var rw in key.ColumnValues)
{
dtTmp.ImportRow(rw);
}
dtTmp.AcceptChanges();
dsTmp.Tables.Add(dtTmp.Copy());
}
dsTmp.AcceptChanges();
string fileName = string.Format("{0}_{1}.xls", this._ID, DateTime.Now.ToString("yyyyMMdd_HHmmss"));
ExcelMultiSheet.ToExcel(dsTmp, fileName, Page.Response);
}
Code Results:
Sheet1
Name | Rate | Date | Code | ROW_SEQ
A | 12 | 01/01/2015 | 12 | 1
B | 13 | 01/01/2015 | 12 | 2
C | 10 | 01/01/2015 | 12 | 3
Sheet2
Name | Rate | Date | Code | ROW_SEQ
Sub Total | 25 | 01/01/2015 | 12 |
Grand Total | 35 | 01/01/2015 | 12 |
Sheet3
Name | Rate | Date | Code | ROW_SEQ
D | 15 | 10/01/2015 | 15 | 1
E | 16 | 10/01/2015 | 15 | 2
F | 10 | 10/01/2015 | 15 | 3
Sheet4
Name | Rate | Date | Code | ROW_SEQ
Sub Total | 31 | 10/01/2015 | 15 |
Grand Total | 41 | 10/01/2015 | 15 |
But i need Results:
Sheet1
Name | Rate | Date | Code | ROW_SEQ
A | 12 | 01/01/2015 | 12 | 1
B | 13 | 01/01/2015 | 12 | 2
Sub Total | 25 | 01/01/2015 | 12 |
C | 10 | 01/01/2015 | 12 | 3
Grand Total | 35 | 01/01/2015 | 12 |
Sheet2
Name | Rate | Date | Code | ROW_SEQ
D | 15 | 10/01/2015 | 15 | 1
E | 16 | 10/01/2015 | 15 | 2
Sub Total | 31 | 10/01/2015 | 15 |
F | 10 | 10/01/2015 | 15 | 3
Grand Total | 41 | 10/01/2015 | 15 |
Thanks advance. :)
You can use like this
var results = from p in persons
group p.car by p.PersonId into g
select new { PersonID = g.Key, Cars = g.ToList() };
I have been beating my head on this for awhile, this is in import form, it imports lines from a excel spreadsheet to a datagridview then allows the user to make sure changes if needed, then adds or updates the db lines.
I have included sample rows from the spreadsheet, and the part of the code that checks the lines. My issue is that 4 of the rows do not flag as prev. found no matter how many times you run it.
Any input?
Sample excel file:
+-------+----------+-----------+------------------+-------+------------+--------+------------------------+
| Trans | Eff Date | Policy # | Insured Name | PIF | GWP | Agent% | Agent NB Comm |
+-------+----------+-----------+------------------+-------+------------+--------+------------------------+
| AV | Jul-10 | 186990710 | FLORECE, BOB | 0 | 0.00 | 10.000 | 0.00 |
| AV | Jul-18 | 193214729 | CIRONIDA, JOHN A | 0 | 0.00 | 10.000 | 0.00 |
| CH | Jun-26 | 186990710 | FLORECE, BOB | 0 | 51.97 | 10.000 | 5.20 |
| CH | Jul-10 | 186990710 | FLORECE, BOB | 0 | (64.83) | 10.000 | (6.48) - NOT MATCHED |
| CH | Jul-10 | 186990710 | FLORECE, BOB | 1 | 272.19 | 10.000 | 27.22 |
| CH | Jul-01 | 192182230 | URZ, SUSAN A | 0 | (50.70) | 10.000 | (5.07) - NOT MATCHED |
| CH | Jul-09 | 193089995 | STOMPKINS, JIM | 0 | 45.37 | 10.00 | 4.54 |
| CH | Jul-18 | 193214729 | CIRONIDA, JOHN A | 1 | 125.99 | 10.000 | 12.60 |
| CH | May-15 | 196666151 | STROP, JONA | 0 | 13.40 | 10.000 | 1.34 |
| CH | May-15 | 196666151 | STROP, JONA | 0 | (13.40) | 10.000 | (1.34) |
| CN | Jul-03 | 193435083 | MADDORE, SHARON | -1 | (1,097.81) | 10.000 | (109.78) - NOT MATCHED |
| NB | Jul-01 | 192182230 | URZ, SUSAN A | 3 | 570.10 | 10.000 | 57.01 |
| CH | Jul-10 | 197907782 | LANSKY, WAYNE | 0 | 4.34 | 10.000 | 0.43 |
| NB | Jul-14 | 184221262 | SMITH, DAN | 2 | 419.60 | 10.000 | 41.96 |
| CH | Jul-03 | 184532495 | MULLEN, ROBERT | 0 | (16.41) | 10.000 | (1.64) - NOT MATCHED |
+-------+----------+-----------+------------------+-------+------------+--------+------------------------+
code:
intDGRow = dgvImported.Rows.Count;
for (int i = 0; i < intDGRow; i++)
{
//set var values from the dgv
strPolicyNum = dgvImported.Rows[i].Cells["policynum"].Value.ToString().Replace(" ", string.Empty);
strEDate = DateTime.Parse(dgvImported.Rows[i].Cells["EffDate"].Value.ToString()).ToShortDateString();
strGWP = dgvImported.Rows[i].Cells["gwp"].Value.ToString().Replace(",", string.Empty);
strPIF = dgvImported.Rows[i].Cells["pif"].Value.ToString();
//check if row matches a current transaction in the DB - if so update matched column to value = matched - checks for match by doing a row count in the DB that match the fields - if only 1 row matches then the transaction is a match
if (dbAccess.RowCount("sales", "policynum = '" + strPolicyNum + "' AND effectivedate = #" + strEDate + "# AND pif = " + strPIF + " AND gwp = " + strGWP) == 1)
{
if (dbAccess.RowCount("sales", "policynum = '" + strPolicyNum + "' AND effectivedate = #" + strEDate + "# AND pif = " + strPIF + " AND gwp = " + strGWP + "AND matched = true") == 1)
{
dgvImported.Rows[i].Cells["Matched"].Value = "PrevMatched"; //update the matched column to reflect this item was previously matched
}
else
{
dgvImported.Rows[i].Cells["Matched"].Value = "Matched"; //update the matched column to reflect this item was matched
}//end sub if / else (prev matched)
}//end if
else
{
dgvImported.Rows[i].Cells["Matched"].Value = "UnMatched"; //update the matched column to reflect this item was not matched
}//end else
dgvImported.Rows[i].Cells["producer"].Value = dbAccess.ValueLookup("SELECT producer FROM sales WHERE policynum = '" + strPolicyNum + "'", "producer"); //lookup the producer for the policy number - should pull the last producer attached to the policy
dgvImported.Rows[i].Cells["SalesID"].Value = dbAccess.ValueLookup("SELECT saleskey FROM sales WHERE policynum = '" + strPolicyNum + "' AND effectivedate = #" + strEDate + "# AND gwp = " + strGWP, "saleskey"); //lookup the saleskey from sales table that matches the transaction
}//end for
}//end if file open
}//end file open button
if you need any additional details let me know.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
The attached file represents a tree structure, that I want to convert into java source code, representing the tree as nested if statements
STOP_WORDS > 0
| NEXT_TYPE > 5: X
| NEXT_TYPE <= 5: Y
STOP_WORDS <= 0
…
If (STOP_WORDS > 0)
{
If (NEXT_TYPE > 5)
{
Return X
}
If ( NEXT_TYPE <= 5)
{
Return Y
}
}
If (STOP_WORDS <= 0)
{
….
}
As you can see, the indentation level using pipe ( | ) symbols represents the parent-child relationship
You can write this program in Java, or if you prefer in any other language you find suitable.
Below is the text file that I need to convert into If statements:
STOP_WORDS > 0
| NEXT_TYPE > 5: 5
| NEXT_TYPE <= 5: 1
STOP_WORDS <= 0
| STREET_TYE > 0
| | PREVIOUS_TYPE > 5: 2
| | PREVIOUS_TYPE <= 5
| | | NEXT_TYPE > 5: 2
| | | NEXT_TYPE <= 5: 5
| STREET_TYE <= 0
| | PERSON_TITLE > 0
| | | NEXT_TYPE <= 5: 4
| | | NEXT_TYPE > 5: 5
| | PERSON_TITLE <= 0
| | | SURNAME > 0
| | | | PREVIOUS_TYPE <= 4: 3
| | | | PREVIOUS_TYPE > 4: 5
| | | SURNAME <= 0
| | | | FIRST_NAME > 0
| | | | | NEXT_TYPE <= 5: 0
| | | | | NEXT_TYPE > 5: 5
| | | | FIRST_NAME <= 0
| | | | | TOKEN_LENGTH <= 1
| | | | | | NEXT_TYPE <= 4: 0
| | | | | | NEXT_TYPE > 4
| | | | | | | NEXT_TYPE <= 5: 1
| | | | | | | NEXT_TYPE > 5: 5
| | | | | TOKEN_LENGTH >1
| | | | | | NEXT_TYPE > 4: 5
| | | | | | NEXT_TYPE <= 4: 0
| | | | | | | PREVIOUS_TYPE <= 1: 4
| | | | | | | PREVIOUS_TYPE >1
| | | | | | | | PREVIOUS_TYPE >3: 4
| | | | | | | | PREVIOUS_TYPE <= 3: 5
My problem is I don't find a logic to keep track of previous If statements and when to close them. As you can see each line has many pipes(|) and sometime less pipe and sometimes more pipes. I don't find the logic for it.
Any help would be appreciated.
Python
with open('input.txt') as f:
indent = 8
prev_depth = -1
closes = []
for line in f:
line = line.strip()
if not line: continue
depth = line.count('|')
while prev_depth >= depth:
prev_depth -= 1
print(closes.pop())
pad = ' ' * (depth*indent)
print(pad + 'If ({})'.format(line.lstrip('| ').split(':', 1)[0]))
print(pad + '{')
closes.append(pad + '}')
if ':' in line:
pad2 = ' ' * ((depth+1)*indent)
print(pad2 + 'Return {}'.format(line[line.find(':')+1:].strip()))
prev_depth = depth
while closes:
print(closes.pop())
Your question is super unclear, but here's a start
barometer = 0
with open('path/to/input') as infile:
for line in infile:
barometer += delta
line = ''.join(itertools.dropwhile(lambda c: c in ' |', line))
if ":" in line:
cond, act = line.split(":",1)
print "If (%s) { Return %s }" %(cond, act)
else:
delta = barometer - sum(1 for i in itertools.takewhile(lambda c: c in ' |', line))
if delta < 0:
print " {}"[delta/abs(delta)]*abs(delta)
print "If (%s) {" %cond
I have to go to sleep now, but this should get you started, at the very least
I've data which looks something like this.
| id | name | depth | itemId |
+-----+----------------------+-------+-------+
| 0 | ELECTRONICS | 0 | NULL |
| 1 | TELEVISIONS | 1 | NULL |
| 400 | Tube | 2 | NULL |
| 432 | LCD | 3 | 1653 |
| 422 | Plasma | 3 | 1633 |
| 416 | Portable electronics | 3 | 1595 |
| 401 | MP3 Player | 3 | 1249 |
| 191 | Flash | 2 | NULL |
| 555 | CD Players | 3 | 2198 |
| 407 | 2 Way Radio | 3 | 1284 |
| 388 | I've a problem with | 3 | 1181 |
| 302 | What is your bill pa | 3 | 543 |
| 203 | Where can I find my | 3 | 299 |
| 201 | I would like to make | 3 | 288 |
| 200 | Do you have any job | 3 | 284 |
| 192 | About Us | 3 | NULL |
| 199 | What can you tell me | 4 | 280 |
| 198 | Do you help pr | 4 | 276 |
| 197 | would someone help co| 4 | 272 |
| 196 | can you help ch | 4 | 268 |
| 195 | What awards has Veri | 4 | 264 |
| 194 | What's the latest ne | 4 | 260 |
| 193 | Can you tell me more | 4 | 256 |
| 180 | Site Help | 2 | NULL |
| 421 | Where are the | 3 | 1629 |
| 311 | How can I access My | 3 | 557 |
| 280 | Why isn't the page a | 3 | 512 |
To convert the above data into unordered list based on depth, I'm using the following code
int lastDepth = -1;
int numUL = 0;
StringBuilder output = new StringBuilder();
foreach (DataRow row in ds.Tables[0].Rows)
{
int currentDepth = Convert.ToInt32(row["Depth"]);
if (lastDepth < currentDepth)
{
if (currentDepth == 0)
{
output.Append("<ul class=\"simpleTree\">");
output.AppendFormat("<li class=\"root\"><span>root</span><ul><li class=\"open\" ><span><a href=\"#\" title={1}>{0}</a></span>", row["name"],row["id"]);
}
else
{
output.Append("<ul>");
if(currentDepth==1)
output.AppendFormat("<li><span>{0}</span>", row["name"]);
else
output.AppendFormat("<li><span class=\"text\"><a href=\"#\" title={1}>{0}</a></span>", row["name"], row["id"]);
}
numUL++;
}
else if (lastDepth > currentDepth)
{
output.Append("</li></ul></li>");
if(currentDepth==1)
output.AppendFormat("<li><span>{0}</span>", row["name"]);
else
output.AppendFormat("<li><span class=\"text\"><a href=\"#\" title={1}>{0}</a></span>", row["name"], row["id"]);
numUL--;
}
else if (lastDepth > -1)
{
output.Append("</li>");
output.AppendFormat("<li><span class=\"text\"><a href=\"#\" title={1}>{0}</a></span>", row["name"],row["id"]);
}
lastDepth = currentDepth;
}
for (int i = 1; i <= numUL+1; i++)
{
output.Append("</li></ul>");
}
myliteral.text=output.ToString();
But the resulting unordered list doesnt seem to be forming properly(using which i am constructing a tree).For example "Site Help" with id '180' is supposed to appear as a direct child of "Televisions" with id '1',is appearing as a direct child of 'Flash' with id '191' using my code.so in addition to considering depth,I've decided to consider itemid as well in order to get the treeview properly.Those rows of the table with itemId not equal to null are not supposed to have a child node(i.e.,they are the leaf nodes in the tree) and all the other nodes can have child nodes.
Please could someone help me in constructing a proper unordered list based on my depth,itemid columns?
Update:
The 'itemid' column refers to the id of an item which is present in another table.This column just helps in identifying if an item has any sub items(i.e., 'name' in my data in this case has any other unordered lists under it).
It looks like the initial code wasn't taking account of the number of levels back up you needed to go from the "Can you tell me more" node to the "Site Help" node.
int lastDepth = -1;
int numUL = 0;
StringBuilder output = new StringBuilder();
foreach (DataRow row in ds.Tables[0].Rows)
{
int currentDepth = Convert.ToInt32(row["Depth"]);
if (lastDepth < currentDepth)
{
if (currentDepth == 0)
{
output.Append("<ul class=\"simpleTree\">");
output.AppendFormat("<li class=\"root\"><span>root</span><ul><li class=\"open\" ><span><a href=\"#\" title={1}>{0}</a></span>", row["name"], row["id"]);
}
else
{
output.Append("<ul>");
if (currentDepth == 1)
output.AppendFormat("<li><span>{0}</span>", row["name"]);
else
output.AppendFormat("<li><span class=\"text\"><a href=\"#\" title={1}>{0}</a></span>", row["name"], row["id"]);
}
numUL++;
}
else if (lastDepth > currentDepth)
{
//output.Append("</li></ul></li>");
output.Append("</li>");
for (int i = lastDepth; i > currentDepth; i--)
{
output.Append("</ul></li>");
}
if (currentDepth == 1)
output.AppendFormat("<li><span>{0}</span>", row["name"]);
else
output.AppendFormat("<li><span class=\"text\"><a href=\"#\" title={1}>{0}</a></span>", row["name"], row["id"]);
numUL--;
}
else if (lastDepth > -1)
{
output.Append("</li>");
output.AppendFormat("<li><span class=\"text\"><a href=\"#\" title={1}>{0}</a></span>", row["name"], row["id"]);
}
lastDepth = currentDepth;
}
for (int i = 1; i <= numUL + 1; i++)
{
output.Append("</li></ul>");
}
myliteral.Text = output.ToString();
Stuart.