FormView

FormView

Old forum URL: forums.lhotka.net/forums/t/3495.aspx


dantes1 posted on Thursday, September 06, 2007

i have this formview with corresponding datasource (dsUser)
my BO is called User (EditableRoot)...

the defaultmode of the formview is insert...

inside the insertitemtemplate i have a telerik control(RadGrid)... i had it populated... then i set it up that when i selected an item... i created a new User Object then populated it with the values i got from the grid(does csladatasource have a current item property like in winforms???)... then i saved it in a session... then on the selectObject event handler i saved it on the e.BusinessObject... then i also saved a value on another session that indicates that the mode has change (its like this everytime i select an item)... coz i want to change the mode of the formview afer i selected an item...

then on the Page_Load i checked the session which indicates the change mode... then called the formview changemode method... then called the formview databind method to bind the csladatasource with the selected item...

when i run it... then selected an item... it changed to the edititemtemplate (edit mode)... but the controls (textbox) which are binded to the datasource dont have any values on them... but before that i checked the value passed to the e.BusinessObject on the selectObject eventhandler... the data i expected was there...

whats my mistake here???

heres the code when the selectedIndexChanged is called

Protected Sub RadGrid2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim grid As Telerik.WebControls.RadGrid = CType(sender, Telerik.WebControls.RadGrid)
        Dim selectUser As Specs.User = Specs.User.NewUser
        selectUser.UserId = CType(grid.MasterTableView.DataKeyValues(CType(grid.SelectedIndexes.Item(0), Integer)).Item("UserId"), String)
        selectUser.UserName = CType(grid.MasterTableView.DataKeyValues(CType(grid.SelectedIndexes.Item(0), Integer)).Item("UserName"), String)
        selectUser.UserGrpId = CType(grid.MasterTableView.DataKeyValues(CType(grid.SelectedIndexes.Item(0), Integer)).Item("UserGrpId"), String)
        selectUser.Status = CType(grid.MasterTableView.DataKeyValues(CType(grid.SelectedIndexes.Item(0), Integer)).Item("Status"), String)
        selectUser.Password = ""
        Session("User") = selectUser
        Session("ChangeMode") = True
    End Sub

then heres the code inside the Page_Load when it checks for the session indicating the change mode:

If Not Session("ChangeMode") Is Nothing Then
            Try
                Me.FormView1.ChangeMode(FormViewMode.Edit)
                Me.FormView1.DataBind()
                Session("ChangeMode") = Nothing
            Catch ex As Exception

            End Try

        End If

Copyright (c) Marimer LLC