gridview columns displayed and not

rainbow_man

Member
Joined
Nov 9, 2009
Messages
5
Programming Experience
Beginner
Hi all,

I am using a gridview to display data from a dataset using this code:


VB.NET:
        Dim sd As DataSet1TableAdapters.DataTable2TableAdapter = New DataSet1TableAdapters.DataTable2TableAdapter()
        Dim ds As DataSet1.DataTable2DataTable = New DataSet1.DataTable2DataTable
        Dim selectedToken As String = academicTokensDDL.SelectedItem.ToString
        If selectedToken.Equals("exam") Then
            ds = sd.GetDataByExams(IDTBox.Text)
            GridView2.DataSource = Nothing
            GridView2.DataBind()
            GridView2.DataSourceID = ObjectDataSource2.ID
            GridView2.DataBind()
            GridView2.Visible = True
        Else
            GridView2.Visible = False
        End If
DataTable:
- academicYear
- semester
- installments
- course
- amount
- paymentMethod
- paymentPlan
DataTableTableAdapter
Fill,GetData(@id) ------> main query
FillByExams,GetDataByExams(@id)

the gridview is initially bound to ObjectDataSource1. Its dataset is returning these columns from the main query:

- academicYear
- semester
- installments
- course
- amount
- paymentMethod
- paymentPlan

In the code above, when the selected index of the DDL is changed to 'exam' I need to rebind the datasource of the gridview. Some of the above data columns need to be displayed and some not and some added, like I have an additional 'fees' column. The problem is that the gridview is giving me data columns just as the above and not the correct data returned from getDataByExams(). Any suggestion how to fix this? Thanks.
Reply With Quote
 
Back
Top