Probably various ways of doing this and reasons why some ways are better than others.
I am probably not going about things the best way but owing to my limited experience, it is what it is and any help would be much appreciated.
I have pulled data from a sql database, put into a sqldataadapter, then stored in a session.
Now I wish to retrieve the data from the session (which was stored as a sqldataadpater, not my initial intention), put to a datagrid via a datatable and having retrived the sesison vars through a sqldataadapter.
This all works fine (below).
As my next part of the process I need to compare a piece of the data that is displayed in that datagrid (which had originally been kept in the session as a sqldataadapter).
My first port of call was to simply access and display the relevant data to keep things simple.
This is where I have had difficulties.
I have tried several alternatives and have been unable to find the solution.
A couple of my many attempts (using data from the datagrid, sqldataadapter and the datatable)...
myAspLabel.Text = dtAA.Columns.Item(0).ColumnName("myColName").ToString()
myAspLabel.Text = Convert.ToString(dtAA.Rows("myColName").Item(0))
Sub bindAA()
Dim dtAA As New DataTable()
Dim dtadapter As New SqlDataAdapter()
dtadapter = Session("dataset")
dtadapter.Fill(dtAA)
myDataGrid.DataSource = dtAA
myDataGrid.DataBind()
End Sub
<aspataGrid ID="myDataGrid" runat="server" Width="100%" AutoGenerateColumns="false">
<columns>
<asp:BoundColumn Datafield="CU_AADate" DataFormatString="{0:dd-MM-yyyy}" ReadOnly="true" />
<asp:BoundColumn Datafield="CU_AAValue" DataFormatString="{0:£0.00}" ReadOnly="true" />
<asp:BoundColumn Datafield="CU_AAAVCConts" DataFormatString="{0:£0.00}" ReadOnly="true" />
<asp:BoundColumn Datafield="myColName" DataFormatString="{0:£0.00}" ReadOnly="true" />
</columns>
</aspataGrid>
<asp:Label runat="server" ID="myAspLabel" />
I am sure the answer to this is simple but just need pointing in the right direction.
Many thanks
I am probably not going about things the best way but owing to my limited experience, it is what it is and any help would be much appreciated.
I have pulled data from a sql database, put into a sqldataadapter, then stored in a session.
Now I wish to retrieve the data from the session (which was stored as a sqldataadpater, not my initial intention), put to a datagrid via a datatable and having retrived the sesison vars through a sqldataadapter.
This all works fine (below).
As my next part of the process I need to compare a piece of the data that is displayed in that datagrid (which had originally been kept in the session as a sqldataadapter).
My first port of call was to simply access and display the relevant data to keep things simple.
This is where I have had difficulties.
I have tried several alternatives and have been unable to find the solution.
A couple of my many attempts (using data from the datagrid, sqldataadapter and the datatable)...
myAspLabel.Text = dtAA.Columns.Item(0).ColumnName("myColName").ToString()
myAspLabel.Text = Convert.ToString(dtAA.Rows("myColName").Item(0))
Sub bindAA()
Dim dtAA As New DataTable()
Dim dtadapter As New SqlDataAdapter()
dtadapter = Session("dataset")
dtadapter.Fill(dtAA)
myDataGrid.DataSource = dtAA
myDataGrid.DataBind()
End Sub
<aspataGrid ID="myDataGrid" runat="server" Width="100%" AutoGenerateColumns="false">
<columns>
<asp:BoundColumn Datafield="CU_AADate" DataFormatString="{0:dd-MM-yyyy}" ReadOnly="true" />
<asp:BoundColumn Datafield="CU_AAValue" DataFormatString="{0:£0.00}" ReadOnly="true" />
<asp:BoundColumn Datafield="CU_AAAVCConts" DataFormatString="{0:£0.00}" ReadOnly="true" />
<asp:BoundColumn Datafield="myColName" DataFormatString="{0:£0.00}" ReadOnly="true" />
</columns>
</aspataGrid>
<asp:Label runat="server" ID="myAspLabel" />
I am sure the answer to this is simple but just need pointing in the right direction.
Many thanks