J
Jim Gregg
Hello all,
I am faced with some logic that I am unsure how to handle. Imagine that
I am running a WMI query and I am outputting the data into a
dynamically created ASP table control. Here is my code that does this.
I have left out the portion that connects to my server and the query,
but this should be enough to show what I am doing. Basically it is a
web page that queries SMS for clients in a certain collection, then
outputs the name value and offers a drop down list that has choices for
existing collections that the name can be moved into. I have a seperate
function that does this for me.
Dim objWQL As New WqlObjectQuery(strWQL)
Dim myObjectSearcher As New ManagementObjectSearcher(scope,
objWQL)
Dim myObjectCollection As
System.Management.ManagementObjectCollection
Dim myObject As System.Management.ManagementObject
myObjectCollection = myObjectSearcher.Get()
For Each myObject In myObjectCollection
myClientList.Add(myObject.GetPropertyValue("Name").ToString())
Next
Dim myCounter As Integer = 1
For Each myClient As String In myClientList
Dim myTableRow As New TableRow
Dim myCell1 As New TableCell
Dim myCell2 As New TableCell
Dim ddl As New DropDownList
ddl.Width = 100
ddl.Items.Add("1")
ddl.Items.Add("2")
ddl.Items.Add("3")
myCell1.BackColor = Drawing.Color.Red
myCell2.BackColor = Drawing.Color.Blue
Table1.Rows.Add(myTableRow)
Table1.Rows(myCounter).Cells.Add(myCell1)
Table1.Rows(myCounter).Cells.Add(myCell2)
myCell1.Text = myClient.ToString
myCell2.Controls.Add(ddl)
myCounter = myCounter + 1
Next
So here is my question. I am only returning one value on each iteration
of the for each loop, and that is the name property. I am outputting
this name property in the first cell of a table row, and a am
outputting a drop down list into the second cell of a table. I am
confused as to how I can wire the value in the drop down list to the
name value in cell 1. For example, imagine that I have 4 rows in my
table, each one containing a server name in cell 1, and a drop down
list in cell 2. I also have a submit button after my table is closed.
When I click submit, I am attempting to iterate through each row in the
table, get the server name from cell 1 and the corresponding value from
the drop down in cell 2. I then use these 2 values to feed a function
that does something with the values. I guess I am really having trouble
associating the drop down with the appropriate server name in cell 1 of
each row and then getting the data on submit. So in a nutshell, there
could be multiple rows in the table, each row will have a different
server name (returned from the WMI query) in cell 1 and a drop down in
cell 2. On submit, I have to gather the data from each row, process it,
then move onto the next row until there are no rows left. It is
extremely important that I can get the value from the drop down list in
cell 2 and associate with the server name in each row. Each row could
have unique values in the drop down list. I am unsure how to do this or
if it is even possible. If someone can assist, it would be greatly
appreciated. Thank you in advance for any help that can be offered.
Jim Gregg
I am faced with some logic that I am unsure how to handle. Imagine that
I am running a WMI query and I am outputting the data into a
dynamically created ASP table control. Here is my code that does this.
I have left out the portion that connects to my server and the query,
but this should be enough to show what I am doing. Basically it is a
web page that queries SMS for clients in a certain collection, then
outputs the name value and offers a drop down list that has choices for
existing collections that the name can be moved into. I have a seperate
function that does this for me.
Dim objWQL As New WqlObjectQuery(strWQL)
Dim myObjectSearcher As New ManagementObjectSearcher(scope,
objWQL)
Dim myObjectCollection As
System.Management.ManagementObjectCollection
Dim myObject As System.Management.ManagementObject
myObjectCollection = myObjectSearcher.Get()
For Each myObject In myObjectCollection
myClientList.Add(myObject.GetPropertyValue("Name").ToString())
Next
Dim myCounter As Integer = 1
For Each myClient As String In myClientList
Dim myTableRow As New TableRow
Dim myCell1 As New TableCell
Dim myCell2 As New TableCell
Dim ddl As New DropDownList
ddl.Width = 100
ddl.Items.Add("1")
ddl.Items.Add("2")
ddl.Items.Add("3")
myCell1.BackColor = Drawing.Color.Red
myCell2.BackColor = Drawing.Color.Blue
Table1.Rows.Add(myTableRow)
Table1.Rows(myCounter).Cells.Add(myCell1)
Table1.Rows(myCounter).Cells.Add(myCell2)
myCell1.Text = myClient.ToString
myCell2.Controls.Add(ddl)
myCounter = myCounter + 1
Next
So here is my question. I am only returning one value on each iteration
of the for each loop, and that is the name property. I am outputting
this name property in the first cell of a table row, and a am
outputting a drop down list into the second cell of a table. I am
confused as to how I can wire the value in the drop down list to the
name value in cell 1. For example, imagine that I have 4 rows in my
table, each one containing a server name in cell 1, and a drop down
list in cell 2. I also have a submit button after my table is closed.
When I click submit, I am attempting to iterate through each row in the
table, get the server name from cell 1 and the corresponding value from
the drop down in cell 2. I then use these 2 values to feed a function
that does something with the values. I guess I am really having trouble
associating the drop down with the appropriate server name in cell 1 of
each row and then getting the data on submit. So in a nutshell, there
could be multiple rows in the table, each row will have a different
server name (returned from the WMI query) in cell 1 and a drop down in
cell 2. On submit, I have to gather the data from each row, process it,
then move onto the next row until there are no rows left. It is
extremely important that I can get the value from the drop down list in
cell 2 and associate with the server name in each row. Each row could
have unique values in the drop down list. I am unsure how to do this or
if it is even possible. If someone can assist, it would be greatly
appreciated. Thank you in advance for any help that can be offered.
Jim Gregg