Question : DataGrid Datasource is nothing after postback.  Can't get at the data.

I have a datagrid on a web form which is bound to a datatable, however after postback the datasource of the grid is nothing.

I'm trying to use the same method that I use when using Windows forms, and that is to cast the datasource property of the datagrid back into a datatable, then pass it off to a function that loops through the rows and saves them.

The first condition is fine, it binds data to the grid and display rows in the browser OK, but where do they go after postback?

 If IsPostBack = False Then

            With Me.grdDiary
                .DataSource = myEvents.GetDiaryTable
                .DataBind()
            End With

elseIf IsPostBack = true Then

            Dim myTable As DataTable
           
            myTable = DirectCast(grdDiary.DataSource, DataTable)

end if

Answer : DataGrid Datasource is nothing after postback.  Can't get at the data.

i'm not so sure, but i think that it wouldn't appear in the request.form

but you can use something like that

Dim i As Integer
For i = 0 To YourRepeaterControl.Items.Count
 Dim checked as Boolean
 Dim cb as CheckBox
 cb = CType(YourRepeaterControl.Items(i).FindControl (your_checkbox_control_id ), CheckBox )
 if Not cb = Nothing Then
  checked = cb.Checked
  'perform some action with this checked item
 End If
Next

HTH
B..G
Random Solutions  
 
programming4us programming4us