S
SAL
I am trying to cast my Gridview in my Code behide as a Dataset so I can
manipulate the data. Here is the code snippet:
Dim FilteredDataSet As New System.Data.DataSet
Dim gv As New GridView
gv = CType(tbl_ReportData.FindControl("GridView_1"), GridView)
gv.GridLines = GridLines.Both
gv.DataBind()
FilteredDataSet = DirectCast(gv.DataSource, System.Data.DataSet)
Now the issue I'm running into is the gv.DataSource is Nothing. My
GridView_1 control which I assign my gv to is bound to a <asp:SqlDataSource
ID="SqlDataSource1> on the HTML side and loads GridView_1 fine. Even if I
assign the gv.DataSource as "gv.DataSource =
CType(tbl_ReportData.FindControl("GridView_1"), GridView).DataSource", the
DataSource still shows nothing. When I check
CType(tbl_ReportData.FindControl("GridView_1"), GridView).DataSourceID the is
shows SqlDataSource1.
Can anyone tell why my GridView_1 gets populated just fine but the
DataSource shows NOTHING, which is preventing me from creating a DataSet from
my GridView? If my syntax is wrong can you show me how to fix it?
Thanks,
manipulate the data. Here is the code snippet:
Dim FilteredDataSet As New System.Data.DataSet
Dim gv As New GridView
gv = CType(tbl_ReportData.FindControl("GridView_1"), GridView)
gv.GridLines = GridLines.Both
gv.DataBind()
FilteredDataSet = DirectCast(gv.DataSource, System.Data.DataSet)
Now the issue I'm running into is the gv.DataSource is Nothing. My
GridView_1 control which I assign my gv to is bound to a <asp:SqlDataSource
ID="SqlDataSource1> on the HTML side and loads GridView_1 fine. Even if I
assign the gv.DataSource as "gv.DataSource =
CType(tbl_ReportData.FindControl("GridView_1"), GridView).DataSource", the
DataSource still shows nothing. When I check
CType(tbl_ReportData.FindControl("GridView_1"), GridView).DataSourceID the is
shows SqlDataSource1.
Can anyone tell why my GridView_1 gets populated just fine but the
DataSource shows NOTHING, which is preventing me from creating a DataSet from
my GridView? If my syntax is wrong can you show me how to fix it?
Thanks,