ApexCo
asked on
Using a boolean for conditional updates, why isn't this working?
I've got a bit of an issue and I can't figure it out. I'm doing some updates on a grid and due to the way the update works from the RadGrid I'm trying to implement the following.
I've declared a boolean Dim bRelCode As Boolean and I've got a selectedindexchanged event firing on a dropdown as follows:
Public Sub dropDownList1_SelectedInde xChanged(B yVal sender As Object, ByVal e As EventArgs)
'Load the label using the selected value of first dropdownlist.
'first reference the edited grid item through the NamingContainer attribute
Dim editedItem As GridEditableItem = CType(CType(sender, DropDownList).NamingContai ner, GridEditableItem)
Dim lblRelCode As Label = CType(editedItem("Template ColumnRelC ode").Find Control("R elCode"), Label)
Dim table As DataTable = DataSourceHelperLK.GetData Table(("SE LECT code_ID FROM contrid WHERE ci_title = '" _
+ CType(editedItem("Template ColumnRelC odeDesc"). FindContro l("DropDow nList1"), DropDownList).SelectedItem .Text + "'"))
'Dim lstRelCode As DataList = CType(editedItem("Template ColumnRelC ode").Find Control("l stRelCode" ), DataList)
Dim grid As GridView = CType(editedItem("Template ColumnRelC ode").Find Control("g ridview1") , GridView)
Dim lbl As Label = CType(editedItem("Template ColumnRelC ode").Find Control("R elCode"), Label)
grid.DataSource = table
grid.DataBind()
lbl.Visible = False
bRelCode = True
End Sub
Now that sets my boolean to true and everything is fine at this point, but when I go to do the update portion it seems my boolean is losing the value assigned to it in the dropdown changed event. And when I get to this bit of code in the update sub;
If bRelCode = True Then
grid = TryCast(eeditedItem.FindCo ntrol("Gri dview1"), GridView)
lblRelCode = CType(grid.Rows(Convert.To Int32(0)). Cells(0).F indControl ("lblRelCo de"), Label)
Else
lblRelCode = CType(eeditedItem.FindCont rol("RelCo de"), Label)
End If
My bRelCode = false and the wrong piece of that if..then is firing.
Ideas?
I've declared a boolean Dim bRelCode As Boolean and I've got a selectedindexchanged event firing on a dropdown as follows:
Public Sub dropDownList1_SelectedInde
'Load the label using the selected value of first dropdownlist.
'first reference the edited grid item through the NamingContainer attribute
Dim editedItem As GridEditableItem = CType(CType(sender, DropDownList).NamingContai
Dim lblRelCode As Label = CType(editedItem("Template
Dim table As DataTable = DataSourceHelperLK.GetData
+ CType(editedItem("Template
'Dim lstRelCode As DataList = CType(editedItem("Template
Dim grid As GridView = CType(editedItem("Template
Dim lbl As Label = CType(editedItem("Template
grid.DataSource = table
grid.DataBind()
lbl.Visible = False
bRelCode = True
End Sub
Now that sets my boolean to true and everything is fine at this point, but when I go to do the update portion it seems my boolean is losing the value assigned to it in the dropdown changed event. And when I get to this bit of code in the update sub;
If bRelCode = True Then
grid = TryCast(eeditedItem.FindCo
lblRelCode = CType(grid.Rows(Convert.To
Else
lblRelCode = CType(eeditedItem.FindCont
End If
My bRelCode = false and the wrong piece of that if..then is firing.
Ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.