Scott.Macmaster
November 4th, 2008, 03:56 PM
I'm having a really hard time trying to figure out dynamic controls. I cannot find a single good reference. Does anyone know of any? Anyway, I came across a strange behavior. Could someone explain?
I have a table that lists resources. Each row has an edit button. When clicked it'll hide the edit button and show a save button, cancel button, a drop down list and and text box. This code I had was working aside from another issue.
If assignedResource.cmdEdit.Attributes("Mode") = "Edit" Then
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.cmdEdit)
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.cmdSave)
tableReport.Rows(row).Cells(1).Controls.Add(New LiteralControl(" "))
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.cmdCancel)
tableReport.Rows(row).Cells(1).Controls.Add(New LiteralControl(" "))
assignedResource.cmdEdit.Visible = False
assignedResource.cmdSave.Visible = True
assignedResource.cmdCancel.Visible = True
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.lstResourceState)
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.txtNotes)
Else
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.cmdEdit)
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.cmdSave)
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.cmdCancel)
tableReport.Rows(row).Cells(1).Controls.Add(New LiteralControl(" "))
assignedResource.cmdEdit.Visible = True
assignedResource.cmdSave.Visible = False
assignedResource.cmdCancel.Visible = False
End If
However, I decided it would look better if I had the save/cancel buttons on the right side. Now, it won't save the edit mode status. Everytime it hits the if statement is returns nothing (which of course evaluates to false). Anyway, what is going on here.
If assignedResource.cmdEdit.Attributes("Mode") = "Edit" Then
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.lstResourceState)
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.txtNotes)
tableReport.Rows(row).Cells(1).Controls.Add(New LiteralControl(" "))
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.cmdEdit)
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.cmdSave)
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.cmdCancel)
tableReport.Rows(row).Cells(1).Controls.Add(New LiteralControl(" "))
assignedResource.cmdEdit.Visible = False
assignedResource.cmdSave.Visible = True
assignedResource.cmdCancel.Visible = True
Else
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.cmdEdit)
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.cmdSave)
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.cmdCancel)
tableReport.Rows(row).Cells(1).Controls.Add(New LiteralControl(" "))
assignedResource.cmdEdit.Visible = True
assignedResource.cmdSave.Visible = False
assignedResource.cmdCancel.Visible = False
End If
Thanks,
I have a table that lists resources. Each row has an edit button. When clicked it'll hide the edit button and show a save button, cancel button, a drop down list and and text box. This code I had was working aside from another issue.
If assignedResource.cmdEdit.Attributes("Mode") = "Edit" Then
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.cmdEdit)
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.cmdSave)
tableReport.Rows(row).Cells(1).Controls.Add(New LiteralControl(" "))
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.cmdCancel)
tableReport.Rows(row).Cells(1).Controls.Add(New LiteralControl(" "))
assignedResource.cmdEdit.Visible = False
assignedResource.cmdSave.Visible = True
assignedResource.cmdCancel.Visible = True
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.lstResourceState)
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.txtNotes)
Else
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.cmdEdit)
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.cmdSave)
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.cmdCancel)
tableReport.Rows(row).Cells(1).Controls.Add(New LiteralControl(" "))
assignedResource.cmdEdit.Visible = True
assignedResource.cmdSave.Visible = False
assignedResource.cmdCancel.Visible = False
End If
However, I decided it would look better if I had the save/cancel buttons on the right side. Now, it won't save the edit mode status. Everytime it hits the if statement is returns nothing (which of course evaluates to false). Anyway, what is going on here.
If assignedResource.cmdEdit.Attributes("Mode") = "Edit" Then
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.lstResourceState)
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.txtNotes)
tableReport.Rows(row).Cells(1).Controls.Add(New LiteralControl(" "))
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.cmdEdit)
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.cmdSave)
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.cmdCancel)
tableReport.Rows(row).Cells(1).Controls.Add(New LiteralControl(" "))
assignedResource.cmdEdit.Visible = False
assignedResource.cmdSave.Visible = True
assignedResource.cmdCancel.Visible = True
Else
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.cmdEdit)
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.cmdSave)
tableReport.Rows(row).Cells(1).Controls.Add(assignedResource.cmdCancel)
tableReport.Rows(row).Cells(1).Controls.Add(New LiteralControl(" "))
assignedResource.cmdEdit.Visible = True
assignedResource.cmdSave.Visible = False
assignedResource.cmdCancel.Visible = False
End If
Thanks,