I have never used TreeViews in the past and I want to display a hierarchical structure (recursive relationship of n levels). The data (available in a dataset - retrieved from database query) is in the following structure:
__ID__ | __NAME__ | __PARENT__
1 | Patrick |
2 | Mark |
3 | Scott | 2
4 | Jason |
5 | Julian |
6 | John | 6
7 | Steve |
8 | George | 1
9 | Robert | 1
10 | Rodney | 8
I'm trying to produce the following output
- Patrick [1]
- George [8]
- Rodney [10]
- Robert [9]
- Mark [2]
- Scott [3]
- Julian [5]
- John [6]
- Jason [4]
- Steve [7]
I'm trying to generate the Treeview control but have no experience with Treeviews. Any feedback or examples on how to achieve this would be really appreciated.
To fill the TreeView from a DataTable, try the following code
Dim DataTable1 As New DataTable
Private Sub FillTestTable()
DataTable1.Columns.Add("ID", GetType(Integer))
DataTable1.Columns.Add("NAME", GetType(String))
DataTable1.Columns.Add("PARENT", GetType(Integer))
DataTable1.Columns.Add("LEVEL", GetType(Integer))
DataTable1.Rows.Add(1, "Patrick")
DataTable1.Rows.Add(2, "Mark")
DataTable1.Rows.Add(3, "Scott", 2)
DataTable1.Rows.Add(4, "Jason")
DataTable1.Rows.Add(5, "Julian")
DataTable1.Rows.Add(6, "John", 5)
DataTable1.Rows.Add(7, "Steve")
DataTable1.Rows.Add(8, "George", 1)
DataTable1.Rows.Add(9, "Robert", 1)
DataTable1.Rows.Add(10, "Rodney", 8)
Dim i As Integer
For i = 0 To DataTable1.Rows.Count - 1
Dim ID1 As String = DataTable1.Rows(i).Item("ID").ToString
DataTable1.Rows(i).Item("LEVEL") = FindLevel(ID1, 0)
Next
End Sub
Private Function FindLevel(ByVal ID As String, ByRef Level As Integer) As Integer
Dim i As Integer
For i = 0 To DataTable1.Rows.Count - 1
Dim ID1 As String = DataTable1.Rows(i).Item("ID").ToString
Dim Parent1 As String = DataTable1.Rows(i).Item("PARENT").ToString
If ID = ID1 Then
If Parent1 = "" Then
Return Level
Else
Level += 1
FindLevel(Parent1, Level)
End If
End If
Next
Return Level
End Function
Code for VB.NET WindowsForms application
Private Sub CreateTree()
Dim MaxLevel1 As Integer = CInt(DataTable1.Compute("MAX(LEVEL)", ""))
Dim i, j As Integer
For i = 0 To MaxLevel1
Dim Rows1() As DataRow = DataTable1.Select("LEVEL = " & i)
For j = 0 To Rows1.Count - 1
Dim ID1 As String = Rows1(j).Item("ID").ToString
Dim Name1 As String = Rows1(j).Item("NAME").ToString
Dim Parent1 As String = Rows1(j).Item("PARENT").ToString
If Parent1 = "" Then
TreeView1.Nodes.Add(ID1, Name1)
Else
Dim TreeNodes1() As TreeNode = TreeView1.Nodes.Find(Parent1, True)
If TreeNodes1.Length > 0 Then
TreeNodes1(0).Nodes.Add(ID1, Name1)
End If
End If
Next
Next
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
FillTestTable()
CreateTree()
TreeView1.ExpandAll()
End Sub
Code for ASP.NET application
Private Sub CreateTree()
Dim MaxLevel1 As Integer = CInt(DataTable1.Compute("MAX(LEVEL)", ""))
Dim i, j As Integer
For i = 0 To MaxLevel1
Dim Rows1() As DataRow = DataTable1.Select("LEVEL = " & i)
For j = 0 To Rows1.Count - 1
Dim ID1 As String = Rows1(j).Item("ID").ToString
Dim Name1 As String = Rows1(j).Item("NAME").ToString
Dim Parent1 As String = Rows1(j).Item("PARENT").ToString
If Parent1 = "" Then
TreeView1.Nodes.Add(New TreeNode(Name1, ID1))
Else
Dim Node1 As TreeNode = GetChildByValue(Parent1, TreeView1.Nodes)
If Not Node1 Is Nothing Then
Node1.ChildNodes.Add(New TreeNode(Name1, ID1))
End If
End If
Next
Next
End Sub
Private Function GetChildByValue(ByVal ID1 As String, ByVal NodeCollection1 As TreeNodeCollection) As TreeNode
For Each TreeNode1 As TreeNode In NodeCollection1
If TreeNode1.Value = ID1 Then
Return TreeNode1
Else
Dim TreeNode2 As TreeNode = GetChildByValue(ID1, TreeNode1.ChildNodes)
If Not TreeNode2 Is Nothing Then
Return TreeNode2
End If
End If
Next
Return Nothing
End Function
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
FillTestTable()
CreateTree()
TreeView1.ExpandAll()
End Sub
The big deal here is coming with a generic and adaptable enough algorithm capable of performing the required sorting. Once this is in place, writing the values into the TreeView is straightforward, just adding Nodes and ChildNodes.
Dim NAME(10) As String
Dim PARENT(10) As Integer
Dim curID As Integer = 0
curID = 1
NAME(curID) = "Patrick [" & curID.ToString() & "]"
PARENT(curID) = 0
curID = curID + 1
NAME(curID) = "Mark [" & curID.ToString() & "]"
PARENT(curID) = 0
curID = curID + 1
NAME(curID) = "Scott [" & curID.ToString() & "]"
PARENT(curID) = 2
curID = curID + 1
NAME(curID) = "Jason [" & curID.ToString() & "]"
PARENT(curID) = 0
curID = curID + 1
NAME(curID) = "Julian [" & curID.ToString() & "]"
PARENT(curID) = 0
curID = curID + 1
NAME(curID) = "John [" & curID.ToString() & "]"
PARENT(curID) = 6
curID = curID + 1
NAME(curID) = "Steve [" & curID.ToString() & "]"
PARENT(curID) = 0
curID = curID + 1
NAME(curID) = "George [" & curID.ToString() & "]"
PARENT(curID) = 1
curID = curID + 1
NAME(curID) = "Robert [" & curID.ToString() & "]"
PARENT(curID) = 1
curID = curID + 1
NAME(curID) = "Rodney [" & curID.ToString() & "]"
PARENT(curID) = 8
Dim completed As Boolean = False
Dim firstIteration As Boolean = True
Dim totIDs As Integer = 10
Do
curID = 0
Do
curID = curID + 1
If (firstIteration) Then
If (PARENT(curID) = 0 And TreeView1.FindNode(NAME(curID)) Is Nothing) Then
TreeView1.Nodes.Add(New TreeNode(NAME(curID)))
End If
Else
If (PARENT(curID) > 0) Then
Dim targetNodes As TreeNodeCollection = TreeView1.Nodes
Dim count As Integer = 0
If (TreeView1.FindNode(NAME(curID)) Is Nothing) Then
For Each node As TreeNode In targetNodes
count = count + 1
If (node.Text.Contains("[" & PARENT(curID).ToString() & "]")) Then
node.ChildNodes.Add(New TreeNode(NAME(curID)))
Exit For
End If
Next
End If
End If
End If
Loop While (curID < totIDs)
If (firstIteration) Then
firstIteration = False
Else
Exit Do 'Just two iterations
End If
Loop While (Not completed)
This code relies on two arrays (NAME (strings), which also includes [original position] and PARENT (integers)) and performs the inclusions until the "second level", that is, main nodes and first child nodes.
I guess that you will have enough information to understand how to deal with TreeView and to build an algorithm capable of performing the sorting you want.
Related
this is my code. When i do debugging i have problem at line dtnew(0)("PANEL_ID") = a.Trim
and i have no idea how to solve this. i'm very new in vb.net. Would be great to hear opinions from expert. There is certain part of the code i alter and delete. So im sorry if its seems like not a complete code.
Dim dt As New DataTable
Try
*
open connection *
oraComm.CommandText = "SELECT Panel_ID, CELL_TYPE, IV_RESULT, MODEL_CD,IV_MODE,modelname,stringlength, quantitycell, " & _ " A_CL_LT_A1, A_CL_LT_A2, A_CL_LT_B1, A_CL_LT_B2, " & _ " A_WAF_ID_1, A_WAF_ID_2, A_WAF_ID_3, A_WAF_ID_4, " & _ " B_CL_LT_A1, B_CL_LT_A2, B_CL_LT_B1, B_CL_LT_B2, " & _ " B_WAF_ID_1, B_WAF_ID_2, B_WAF_ID_3, B_WAF_ID_4, " & _ " C_CL_LT_A1, C_CL_LT_A2, C_CL_LT_B1, C_CL_LT_B2, " & _ " C_WAF_ID_1, C_WAF_ID_2, C_WAF_ID_3, C_WAF_ID_4 " & _
"FROM table1 s,table2 m " & _
"WHERE s.areacode ='hawaii' AND m.areacode ='hawaii' AND s.panel_id = '" & Me.TextBox1.Text.Trim & "' "
ada = New Oracle.DataAccess.Client.OracleDataAdapter(oraComm)
ada.Fill(ds.Tables("M_DATANEW"))
dt = ds.Tables("M_DATANEW")
Dim a, c, d, e, f As String
Dim dtnew = New DataTable()
dtnew.Columns.Add("PANEL_ID", GetType(String))
dtnew.Columns.Add("CELL_TYPE", GetType(String))
dtnew.Columns.Add("IV_RESULT", GetType(String))
dtnew.Columns.Add("IV_MODE", GetType(String))
dtnew.Columns.Add("MODEL_CD", GetType(String))
a = dt.Rows(0)("panel_id").ToString.Trim
c = dt.Rows(0)("cell_type").ToString.Trim
d = dt.Rows(0)("iv_result").ToString.Trim
e = dt.Rows(0)("iv_mode").ToString.Trim
f = dt.Rows(0)("model_cd").ToString.Trim
Dim waf_ini As String = ""
For w = 1 To CInt(dt.Rows(0)("stringlength")) + 1
For x = 1 To CInt(dt.Rows(0)("cellquantity")) + 1
If w = 1 Then
waf_ini = "A_WAF_ID"
ElseIf w = 2 Then
waf_ini = "B_WAF_ID"
ElseIf w = 3 Then
waf_ini = "C_WAF_ID"
End If
dtnew.NewRow()
dtnew(0)("PANEL_ID") = a.Trim
dtnew(0)("CELL_TYPE") = c.Trim
dtnew(0)("IV_RESULT") = d.Trim
dtnew(0)("IV_MODE") = e.Trim
dtnew(0)("MODEL_CD") = f.Trim
dtnew.Rows.Add()
Next
Next
If dt.Rows.Count < > 0 Then
GridView1.DataSource = dt
GridView1.DataBind()
Else
GridView1.DataSource = Nothing
GridView1.DataBind()
End If
Catch ex As Exception
Throw ex
Finally
*
close connection *
End Try
End Sub
You have to create a new row before populating it.
dtnew.Rows.Add(dtnew.NewRow)
a = dtnew.Rows(0)("panel_id").ToString.Trim
c = dtnew.Rows(0)("cell_type").ToString.Trim
d = dtnew.Rows(0)("iv_result").ToString.Trim
e = dtnew.Rows(0)("iv_mode").ToString.Trim
f = dtnew.Rows(0)("model_cd").ToString.Trim
I'm trying to take this string:
(("DISPLAY_NAME" like N'sadf%') And ("ID" = 2) And ("IsCRITERION" = null))
and parse it into a List(of string) so that it can be displayed like:
(
(
"DISPLAY_NAME" like N'sadf%'
)
And
(
"ID" = 2
)
Or
(
"IsCRITERION" = null
)
)
I'm close but don't quite have it. My code currently looks like:
Dim filterlist As New List(Of String)
Dim temp As String = String.Empty
Dim lvl As Integer = 0
Dim pad As String = String.Empty
For Each chr As Char In originalString '--- filter is the string i posted above
Select Case chr.ToString.ToLower()
Case "("
filterlist.Add(pad.PadLeft(lvl * 5) & chr)
lvl += 1
Case ")"
filterlist.Add(pad.PadLeft(lvl * 5) & temp)
If lvl > 0 Then lvl -= 1
filterlist.Add(pad.PadLeft(lvl * 5) & chr)
'If lvl > 0 Then lvl -= 1
temp = String.Empty
Case Else
temp &= chr
End Select
Next
'--- Removes the empty line produced by generating the List(of String)
filterlist = filterlist.Where(Function(s) Not String.IsNullOrWhiteSpace(s)).ToList()
listSelectedCriteria.DataSource = filterlist
listSelectedCriteria.DataBind()
Unfortunately, the above code produces something close to what I desire but the "And"s and "Or"s are not in the right places:
(
(
"DISPLAY_NAME" like N'sadf%'
)
(
And "ID" = 2
)
(
Or "IsCRITERION" = null
)
)
Would using regular expressions be better? Thanks for the help
Probably the "best" way (although that's getting into "primarily opinion-based" territory) would be to use a parser, but assuming that your input is limited to similar looking strings, here's what I came up with:
Dim originalString = "((""DISPLAY_NAME"" like N'sadf%') And (""ID"" = 2) And (""IsCRITERION"" = null))"
Dim filterlist = New List(Of String)()
Dim temp = New StringBuilder()
Dim lvl = 0
Dim addLine =
Sub(x As String)
filterlist.Add(New String(" ", lvl * 4) & x.Trim())
End Sub
For Each c In originalString
Select Case c
Case "("
If temp.Length > 0 Then
addLine(temp.ToString())
temp.Clear()
End If
addLine("(")
lvl += 1
Case ")"
If temp.Length > 0 Then
addLine(temp.ToString())
temp.Clear()
End If
lvl -= 1
addLine(")")
Case Else
temp.Append(c)
End Select
Next
If temp.Length > 0 Then
addLine(temp.ToString())
temp.Clear()
End If
filterlist.Dump() ' LINQPad ONLY
This results in:
(
(
"DISPLAY_NAME" like N'sadf%'
)
And
(
"ID" = 2
)
And
(
"IsCRITERION" = null
)
)
However, you will probably end up having to add code as you find different inputs that don't quite work how you want.
Instead of looking at each characters, I would start be doing a split. And then add/remove padding depending on what character is at the start.
Dim tempString As String = "((""DISPLAY_NAME"" like N'sadf%') And (""ID"" = 2) And (""IsCRITERION"" = null))"
Dim curPadding As String = ""
Const padding As String = " "
Dim result As New List(Of String)
For Each s As String In Text.RegularExpressions.Regex.Split(tempString, "(?=[\(\)])")
If s <> "" Then
If s.StartsWith("(") Then
result.Add(curPadding & "(")
curPadding &= padding
result.Add(curPadding & s.Substring(1).Trim())
ElseIf s.StartsWith(")") Then
curPadding = curPadding.Substring(padding.Length)
result.Add(curPadding & ")")
result.Add(curPadding & s.Substring(1).Trim())
Else
result.Add(curPadding & s)
End If
End If
Next
I have created a Form in MSAccess 2010 and when running I am getting following error :
The select statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect.
The name of my Database is Accessexp
Here is my code:
Private Sub SearchButton_Click()
Dim dbs As Database
Dim rs As Recordset
Dim qdf As QueryDef
Dim productName As String
Dim lastNQuarters As String
Dim strSql As String
Dim columns As String
Dim compstr As String
Dim curstr As String
Dim timestr As String
Dim tablestr As String
Dim sumstr As String
Dim varItem As Variant
Dim compcount As Integer
Dim colcount As Integer
Dim errorcount As Integer
Dim Monthvalue As String
Set dbs = CurrentDb()
errorcount = 0
colcount = 0
lastNQuarters = Me!quarterbox.Value
tablestr = ""
timestr = Me!Monthbox.Value
MsgBox (timestr)
tablestr = "Q" & lastNQuarters
For Each varItem In Me!columnlist.ItemsSelected
If Me!columnlist.ItemData(varItem) <> "---" Then
columns = columns & "," & Chr(34) & Me!columnlist.ItemData(varItem) & Chr(34)
colcount = colcount + 1
End If
Next varItem
compcount = 0
For Each varItem In Me!practicelist.ItemsSelected
compstr = compstr & "," & Chr(34) & Me!practicelist.ItemData(varItem) & Chr(34)
compcount = compcount + 1
Next varItem
If compcount = 0 Then MsgBox ("Warning: No Practice Selected"): errorcount = errorcount + 1
If colcount = 0 Then MsgBox ("Warning: No Practice Selected"): errorcount = errorcount + 1
If errorcount = 0 Then
lastNQuarters = Me!quarterbox.Value
strSql = "Select " & columns & ", " & tablestr & " from Accessexp where Accessexp.[Quarter] = " & tablestr & " and Accessexp.[Month] = " & timestr & ";"
MsgBox (strSql)
Set rs = dbs.OpenRecordset(strSql, dbOpenSnapshot)
With dbs
Set qdf = .CreateQueryDef("QueryOutput", strSql)
DoCmd.OpenQuery "QueryOutput"
.QueryDefs.Delete "QueryOutput"
End With
dbs.Close
qdf.Close
End If
End Sub
My query is coming like this :
Select ,"Revenue Blended","Revenue Direct" Q4
from Accessexp
where Accessexp.[Quarter] = Q4 and Accessexp.[Month] = April;
Is there any other way to seperate values with commas and not putting in begining
After you've built your string with the leading comma just use
columns = Mid(columns, 2)
to trim off the first character.
Other notes:
Wrap your column names in square brackets, not double quotes
String literals need to be enclosed in quotes.
Your resulting query string should look more like this:
Select [Revenue Blended],[Revenue Direct]
from Accessexp
where Accessexp.[Quarter] = 'Q4' and Accessexp.[Month] = 'April';
Try this updated Code.
Private Sub SearchButton_Click()
Dim dbs As Database, rs As Recordset
Dim qdf As QueryDef
Dim productName As String, lastNQuarters As String
Dim strSql As String, columns As String, compstr As String
Dim curstr As String, timestr As String, tablestr As String
Dim sumstr As String, varItem As Variant
Dim compcount As Integer, colcount As Integer, errorcount As Integer
Dim Monthvalue As String
Set dbs = CurrentDb()
errorcount = 0
colcount = 0
lastNQuarters = Me!quarterbox.Value
tablestr = ""
timestr = Me!Monthbox.Value
MsgBox timestr
tablestr = "Q" & lastNQuarters
For Each varItem In Me!columnlist.ItemsSelected
If Me!columnlist.ItemData(varItem) <> "---" Then
columns = columns & "[" & Me!columnlist.ItemData(varItem) & "],"
colcount = colcount + 1
End If
Next
compcount = 0
For Each varItem In Me!practicelist.ItemsSelected
compstr = compstr & "[" & Me!practicelist.ItemData(varItem) & "],"
compcount = compcount + 1
Next
If compcount = 0 Then
MsgBox ("Warning: No Practice Selected")
errorcount = errorcount + 1
Else
compstr = Left(compstr, Len(compstr)-1)
End If
If colcount = 0 Then
MsgBox ("Warning: No Practice Selected")
errorcount = errorcount + 1
Else
columns = Left(columns, Len(columns)-1)
End If
If errorcount = 0 Then
lastNQuarters = Me!quarterbox.Value
strSql = "SELECT " & columns & " FROM Accessexp WHERE Accessexp.[Quarter] = '" & tablestr & "'" & _
" AND Accessexp.[Month] = '" & timestr & "';"
MsgBox (strSql)
Set rs = dbs.OpenRecordset(strSql, dbOpenSnapshot)
With dbs
Set qdf = .CreateQueryDef("QueryOutput", strSql)
DoCmd.OpenQuery "QueryOutput"
'.QueryDefs.Delete "QueryOutput"
End With
dbs.Close
qdf.Close
End If
End Sub
I have two datatables. One datatable that has account and balance and the other datatable has the fee and the balance. For example:
Datatable 1
111111 35.00
111112 50.00
Datatable 2
111111sf 5.00
111112sf 8.00
New datatable should show the account from datatable 1 and the total balance(datatable 1 and datatable 2)
111111 40.00
111112 58.00
how can I compare the two datatables to go through each row and add these values and then create a new datatable? I did it with three gridviews and List(Of string) but it was dirty. I would appreciate any help.
Here is my code:
sqladapter = New SqlDataAdapter("SELECt account, balance FROM DEBT WHERE (account = #account)", conn)
sqladapter = New SqlDataAdapter("SELECt account, balance FROM DEBT WHERE (account = #account)", conn)
Dim ds As New DataSet()
sqladapter.SelectCommand.Parameters.AddWithValue("#account", 111111)
sqladapter2.SelectCommand.Parameters.AddWithValue("#account", 111111)
sqladapter.Fill(ds, "WithSFDT")
sqladapter2.Fill(ds, "WithoutSFDT")
'get datatable
Dim dtWith As DataTable = ds.Tables("WithSFDT")
Dim dtWithout As DataTable = ds.Tables("WithoutSFDT")
Here is the dirty code in gridview:
Dim itemlist As New List(Of String)
For Each row1 As GridViewRow In GridView1.Rows
If row1.RowType = DataControlRowType.DataRow Then
Dim gv1Value As String = row1.Cells(1).Text
Dim gv1col3 As Decimal = row1.Cells(2).Text
Dim lname As String = row1.Cells(3).Text
Dim fname As String = row1.Cells(4).Text
Dim TOdate As DateTime = row1.Cells(5).Text
Dim debtnum As Integer = row1.Cells(6).Text
For Each row2 As GridViewRow In GridView2.Rows
If row2.RowType = DataControlRowType.DataRow Then
Dim gv2Value As String = row2.Cells(3).Text
Dim gv2col3 As Decimal = row2.Cells(1).Text
If gv1Value.Contains(gv2Value) Then
GridView1.Visible = False
GridView2.Visible = False
GridView3.Visible = True
itemlist.Add(TOdate & " | " & gv1Value & " | " & fname & " " & lname & " " & " | " & gv1col3 + gv2col3 & " " & " | " & debtnum)
ElseIf gv2Value Is Nothing Then
GridView3.Visible = False
GridView1.Visible = True
'itemlist.Add(gv1col3 + gv2col3)
'list2.Add(gv1Value)
End If
End If
Next
End If
Next
If itemlist.Count > 0 Then
GridView3.DataSource = itemlist
GridView3.DataBind()
GridView3.HeaderRow.Cells(0).Text = "T/O Date" & " | " & " Account" & " | " & " Name" & " | " & "Balance" & " | " & "Debt #"
' GridView3.HeaderRow.Cells(1).Text = " Balance"
'GridView4.Columns.Add(
GridView3.Visible = True
End If
The problem with is is that the Gridview3 shows the itemlist in one row and it doesn't look like a table.
I've created a dynamic drop down list and the number of drop down list is equal to total days in the selected month.
I've put all drop down in asp:table but i cant get the data form drop down list
and cant fire the selectedindexchange event.
my code is given below
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Table2.Rows(0).Cells(0).Text = v1_drop_month.SelectedItem.Text
helper.return_month(v1_drop_month.SelectedItem.Text)
i = 1
For row = 0 To 6
For cell = 1 To 7
Dim dd As New DropDownList
Dim label As New Label
If row = 0 And cell = 1 Then
Table2.Rows(row).Cells(cell - 1).BackColor = Drawing.Color.Teal
ElseIf row = 1 Then
Table2.Rows(1).Cells(cell - 1).Font.Size = 14
Table2.Rows(1).Cells(cell - 1).HorizontalAlign = HorizontalAlign.Center
Table2.Rows(1).Cells(cell - 1).ForeColor = Drawing.Color.White
Table2.Rows(1).Cells(cell - 1).BackColor = Drawing.Color.Black
ElseIf row >= 2 Then
If i <= helper.month_num Then
dates = helper.Month_no & "-" & i & "-" & v1_drop_month.SelectedItem.Text.Substring(4, 4)
day = New DateTime(v1_drop_month.SelectedItem.Text.Substring(4, 4), helper.Month_no, i)
If Table2.Rows(1).Cells(cell - 1).Text = day.DayOfWeek.ToString() Then
label.Text = i
label.Font.Size = 20
label.ForeColor = Drawing.Color.Red
Table2.Rows(row).Cells(cell - 1).HorizontalAlign = HorizontalAlign.Right
label.ID = row & "-" & cell
Table2.Rows(row).Cells(cell - 1).Controls.Add(label)
If day.DayOfWeek.ToString() <> "Sunday" Then
label.ForeColor = Drawing.Color.Blue
Table2.Rows(row).Cells(cell - 1).Controls.Add(dd)
dd.ID = "dd" & row & "-" & cell
sql = String.Empty
sql = "select distinct route_number from fr_route where territory='" & v1_drop_territory.SelectedItem.Text & "' and state='" & v1_drop_state.SelectedItem.Text & "' and hq='" & v1_drop_hq.SelectedItem.Text & "'"
helper.dropdown_change(sql, "route_number", dd)
Table2.Rows(row).Cells(cell - 1).BackColor = Drawing.Color.SkyBlue
dd.BackColor = Drawing.Color.Khaki
Table2.Rows(row).Cells(cell - 1).Height = 50
End If
i = i + 1
End If
Else
End If
End If
Next
Next
v1_but_save.Visible = True
v1_but_reset.Visible = True
v1_but_send.Visible = True
End Sub
I've used asp:table for the show dropdown menu
Enable "AutoPostBack=True" for dropdownlist