how do i pass data table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hey all,
i have a gridView with editing available. when a user clicks the update link
for a row, how do i pass the entire data table as a parameter to my business
layer?

thanks,
rodchar
 
i thought you could simply access GridView.DataSource but in my tests,
"this.GridView1.DataSource" is null after a postback. as a work-around, you
could add the DataTable to the Viewstate before the edit event (i.e. the
first page_load), and then access it from Viewstate for the edit postback.
Or you could just refetch the datatable.

does that make sense?
tim
 
What I do in many circumstances, is, like the last post said, pass the
DataTable to viewstate as a property of the class:
Private Property EmployeeData() As System.Data.DataTable
Get
Dim o As Object = ViewState("EmployeeData")
If o Is Nothing Then
Return Nothing
Else
Return o
End If
End Get
Set(ByVal value As System.Data.DataTable)
ViewState("EmployeeData") = value
End Set
End Property
 
thank you.

David Wier said:
What I do in many circumstances, is, like the last post said, pass the
DataTable to viewstate as a property of the class:
Private Property EmployeeData() As System.Data.DataTable
Get
Dim o As Object = ViewState("EmployeeData")
If o Is Nothing Then
Return Nothing
Else
Return o
End If
End Get
Set(ByVal value As System.Data.DataTable)
ViewState("EmployeeData") = value
End Set
End Property

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com
 
Back
Top