how do i pass data table

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
 
T

Tim_Mac

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
 
D

David Wier

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top