Dataview newbie

M

Migs

Hi,


I have a dataview named dvContacts, a drop down list named ddlContacts and a
data grid named dgContacts

The drop down list is bound to a dataset with all contact names and when i
click a name i want my grid to be populated with that specific contacts'
details.
I use the dataview to do the selection and populate the datagrid.

Now I got this working but it requires me to use my adaptor to refill my
dataset. Isn't there anyway I can avoid this additional trip to my server.
I thought a dataview is a static view of the data within a dataset???


This is the code that works but I don't understand why I must do an
adapter.fill command.
Private Sub ddlContacts_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ddlContacts.SelectedIndexChanged

'Set the dataview's filter

dvContacts.RowFilter = "ContactID=" & ddlContacts.SelectedItem.Value

SqlDataAdapterContacts.Fill(dsContacts1)

dgContacts.DataBind()

End Sub
 
G

Guest

Hi

I don't think that you need to refill the dataset
What happened if you don't call Fill(dsContacts1)
The problem might be
You define dsContacts as a public variable, however, it does not persist during postback
I guess there is an autopostback for ddlContacts
So when you first fill dsContacts1

If not ispostback the
SqlDataAdapterContacts.Fill(dsContacts1
ViewState("dsContacts1") = dsContacts
Els
dsContacts1 = ViewState("dsContacts1")
End I

Hope this help

Bin Song, MC
 

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

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,279
Latest member
LaRoseDermaBottle

Latest Threads

Top