Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have Created Dynamically a HTML
table by Using String Bulider.
and Filled the Table with Database Values.
My requirement is to Compare the consecutive Cells Values .
How can I do this .please assist.

------
VB
here is what i have Done
Dim s As New StringBuilder

sSql = "SP_GetValFrmDB '" & param1 & "','" & param2 & "'"
Dim sdt As New SqlDataAdapter(sSql, connects)
sdt.Fill(dtt)

s.Append("<html>")
s.Append("<head>")
s.Append("</head>")
s.Append("<body>")
s.Append("<table>")
s.Append("<tr>")
s.Append("<td>")
s.Append("UID NO")
s.Append("</td>")

s.Append("<td>")
s.Append("Item")
s.Append("</td>")

s.Append("</tr>")

For Each drowt As Data.DataRow In dtt.Rows

Dim uID As String = drowt("uIDNo")
Dim item As String = drowt("itemNm")

s.Append("<tr>")
s.Append("<td>")

s.Append("" & uID & "")
s.Append("</td>")
s.Append("<td>")
s.Append("" & item & "")
s.Append("</td>")
s.Append("</tr>")
Next

s.Append("</table>")


s.Append("</body>")
s.Append("</html>")

Response.Write(s)



for ex the Data OutPut is
UID NO --- Item
123 --- A
123-1 --- B
222 --- C
222-1 --- D
333 --- Z

and I need to Compare UID NOs
like in this Case consecutive cells 123 and Then next 123-1
then i need to Put "---" mark in the Second Cell

the Otput i want is
UID NO --- Item
123 --- A
--- --- B
222 --- C
--- --- D
333 --- Z

May you understand my Question Now.
Posted
Updated 29-Aug-13 21:04pm
v5
Comments
Jameel VM 29-Aug-13 9:41am    
Please post the code what you have tried
vinay.tatipamula 29-Aug-13 9:44am    
Please elaborate your question.
enhzflep 29-Aug-13 9:44am    
First, get a reference to your table. Next, you can just compare the innerHTML value for the two cells you want to check. The table has an array called rows and each element of this array has an array called cells.

So, say you want to compare row0,cell0 with row0,cell1:

var tbl = document.getElementById('insert_id_of_your_table_here');
var row0 = tbl.rows[0];
var cell_0 = row0.cells[0];
var cell_1 = row0.cells[1];
if (cell_0.innerHTML == cell_1.innerHTML)
doSomething();
else
doSomethingElse();
Jameel VM 29-Aug-13 9:52am    
Please post the html table mark up also by improving the question.Please don't put codes in comment box
enhzflep 29-Aug-13 11:06am    
Out of curiosity Jameel, what advantage do you think posting the 'html table markup' would provide?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900