Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
bubberz
Constraint Violating Yak Guru
289 Posts |
Posted - 2005-11-27 : 13:12:32
|
I'm working through the MCAD training, and can't seems to get a dropdownlist to populate from a cached dataset:**********Here's the code on the first page:Private Sub Page_Load(....)If Not IsPostBack Then AddtoCache("adptCalls", DA1) AddtoCache("adptContactTypes", DA2) AddtoCache("adptContacts", DA3) 'Fill data sets and add them to Cache DA1.Fill(DsCalls1) AddtoCache("DSCalls", DsCalls1) DA2.Fill(DsContactTypes1) AddtoCache("DSContactTypes", DsContactTypes1) DA3.Fill(DsContacts1) AddtoCache("DSContacts", DsContacts1) End IfEnd SubSub AddtoCache(ByVal Name As String, ByVal Item As Object) 'if item already in cache, simply return If Not IsNothing(Cache(Name)) Then Return 'Otherwise cache item for 20min w/ sliding expiration Cache.Add(Name, Item, Nothing, DateTime.MaxValue, System.TimeSpan.FromMinutes(20), Caching.CacheItemPriority.Default, Nothing) End Sub**********The second page has:Private Sub Page_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load ' Get the Cached variables. adptContacts = Cache("adptContacts") dsContacts = Cache("dsContacts") dsContactTypes = Cache("dsContactTypes") If Not IsPostBack Then ' Bind to data -- populates lists. drpContactTypes.DataSource = dsContactTypes drpContactTypes.DataTextField = "ContactType" drpContactTypes.DataValueField = "ContacTypeID" drpContactTypes.DataBind() drpStates.DataBind() End If ' If there was an unhandled error, display it. If Session("Error") <> "" Then litStatus.Text = Session("Error") ' Reset the error message. Session("Error") = Nothing End If End Sub |
|
saglamtimur
Yak Posting Veteran
91 Posts |
Posted - 2005-11-27 : 17:11:57
|
First, dont add dataadapter to cache. Just add DataSet(s). Second, -as I know- cache names are case sensetive. If you add "DSContacts" you must call "DSContacts", not "dsContacts". Third, I see you assign like dsContacts = Cache("dsContacts"). So what it dsContacts? dataset? datatable?. Its name looks like its a dataset but its better you expilictly "Dim" it. Dim dsContacts as DataSet = Cache("dsContacts"). As I know VB.Net dynamicly convert objects, but Its better to use likeDim dsContacts as DataSet = Ctype(Cache("dsContacts"),DataSet)And finally I could see a datasource for drpStates, but you use drpStates.DataBind().Good Luck |
 |
|
bubberz
Constraint Violating Yak Guru
289 Posts |
Posted - 2005-11-28 : 16:23:51
|
Thanks saglamtimur!the dropdownlist, drpStates, is from an Array string I have in the page. That works, but thanks for checking on that one. I'll look into the spelling and let you know! |
 |
|
bubberz
Constraint Violating Yak Guru
289 Posts |
Posted - 2005-12-02 : 23:12:57
|
It was the case sensitive issue for not populating my ddl.Thanks! |
 |
|
|
|
|
|
|