| Hi everyone, I've been programming for many years, but have just started teaching myself .NET within the last year.. and I have an issue, in which I could use some of your expert advice  (This is developed in vb.net) I'm populating a Datalist on page load (if not ispostback). There are are a series of controls, within the datalist (labels, a textbox, a hyperlink, a button & a dropdownlist). When the button is clicked (CommandName = AddToCart), I'm retrieving the values of these controls and populating some session variables. It works great for the textbox & dropdownlist, but for some reason I'm unable to retrieve the values from the labels & hyperlink. The code compiles properly and executes properly, but the values from the labels & hyperlink are blank. At this point, all of the controls, including the datalist, have enableviewstate = true Here is the code, that I have within the Itemlist_ItemCommand sub procedure: ************** If e.CommandName = "AddToCart" Then Session("item_id") = CType(e.Item.FindControl("lbl_item_id"), Label).Text Session("item_desc") = CType(e.Item.FindControl("hlinkitem_title"), HyperLink).Text Session("price") = CType(e.Item.FindControl("price"), Label).Text Session("quantity") = CType(e.Item.FindControl("lblqty"), TextBox).Text If CType(e.Item.FindControl("ddlsizes"), DropDownList).Enabled = True Then Session("size_id") = CType(e.Item.FindControl("ddlsizes"), DropDownList).SelectedItem.Value Session("size") = CType(e.Item.FindControl("ddlsizes"), DropDownList).SelectedItem.Text Else Session("size_id") = "0" Session("size") = "No Size" End If End If *************** Here is the trace, of the itemlist: (The problem controls seem to be the 'databoundliteralcontrols'... This is where i could use some learning & your help)... Itemlist System.Web.UI.WebControls.DataList 5637 76 Itemlist:_ctl0 System.Web.UI.WebControls.DataListItem 0 0 Itemlist:_ctl0:_ctl0 System.Web.UI.LiteralControl 0 0 Itemlist:_ctl1 System.Web.UI.WebControls.DataListItem 1288 0 Itemlist:_ctl1:_ctl0 System.Web.UI.LiteralControl 39 0 Itemlist:_ctl1:image System.Web.UI.WebControls.HyperLink 133 116 Itemlist:_ctl1:_ctl1 System.Web.UI.LiteralControl 15 0 Itemlist:_ctl1:title1 System.Web.UI.WebControls.Label 58 0 Itemlist:_ctl1:_ctl2 System.Web.UI.DataBoundLiteralControl 5 12 Itemlist:_ctl1:_ctl3 System.Web.UI.LiteralControl 15 0 Itemlist:_ctl1:hlinkitem_title System.Web.UI.WebControls.HyperLink 106 76 Itemlist:_ctl1:_ctl4 System.Web.UI.DataBoundLiteralControl 35 52 Itemlist:_ctl1:_ctl5 System.Web.UI.LiteralControl 15 0 Itemlist:_ctl1:price System.Web.UI.WebControls.Label 58 0 Itemlist:_ctl1:_ctl6 System.Web.UI.DataBoundLiteralControl 6 16 Itemlist:_ctl1:_ctl7 System.Web.UI.LiteralControl 23 0 Itemlist:_ctl1:lblqty System.Web.UI.WebControls.TextBox 136 0 Itemlist:_ctl1:_ctl8 System.Web.UI.LiteralControl 24 0 Itemlist:_ctl1:ddlsizes System.Web.UI.WebControls.DropDownList 0 124 Itemlist:_ctl1:_ctl9 System.Web.UI.LiteralControl 15 0 Itemlist:_ctl1:btnbuy System.Web.UI.WebControls.Button 260 68 Itemlist:_ctl1:_ctl10 System.Web.UI.LiteralControl 15 0 Itemlist:_ctl1:rval_qty System.Web.UI.WebControls.RangeValidator 289 0 Itemlist:_ctl1:_ctl11 System.Web.UI.LiteralControl 15 0 Itemlist:_ctl1:lbl_item_id System.Web.UI.WebControls.Label 59 0 Itemlist:_ctl1:_ctl12 System.Web.UI.DataBoundLiteralControl 1 8 Itemlist:_ctl1:_ctl13 System.Web.UI.LiteralControl 13 0 ***************** Here are the session state traces, that I'm failing to retrieve values. (the dropdownlist and textbox return values correctly, but not the labels & hyperlink) item_id System.String item_desc System.String price System.String ***************** Along with CType, I have also attempted Directcast, with no luck.. Can anyone offer some much needed advice? I'm sure I'm doing something stupid, but please be gentle
..:: Bare ::.. http://www.livingformetal.com
|