Posts

Showing posts from October, 2008

DorpDownList in DL set by value in Database

Sub dlComponent_databind( ByVal sender As Object , ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Dim drpMarket As DropDownList = CType (e.Item.FindControl( "drpStatus" ), DropDownList) drpMarket.Items.Insert(0, "No Selection Specified" ) drpMarket.SelectedValue = Trim(e.Item.DataItem.componentStatus) Dim drpCo As DropDownList = CType (e.Item.FindControl( "drpCompany" ), DropDownList) drpCo.Items.Insert(0, "No Selection Specified" ) drpCo.SelectedValue = Trim(e.Item.DataItem.company) End Sub

Keeping Dynamic Controls Dynamic

Part of the issue with including User Controls in a page by adding them in the top of the page like this: <% @ Register TagPrefix ="HMD" TagName ="Assortment" Src ="~/Controls/assortments.ascx" %> is that if the content is something like say a shopping cart or dropdownlists generated from a database or something where the state and the refreshed load is terribly important  - a solution is to load the control dynamically based on an event.  Dim the control and add it to the page via a literal or panel or table cell or some other object that could house it.  This assures that the control is loaded fresh everytime it needs to be. Dim ctlStoreSku As Control = LoadControl( "controls/skuweekly.ascx" ) myPanel.Controls.Add(ctlStoreSku) myPanel.Visible = True That's  it....