If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Visual Basic > gridview refresh columns

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-08-10, 17:22
kpeeroo kpeeroo is offline
Registered User
 
Join Date: Jul 2009
Posts: 143
gridview refresh columns

Hi all,

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

Code:
        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
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On