E
Ed Dror
Hi there,
I'm using asp.net 2.0 with SQL Server 2005
I created a datalist control and I would like to read the results into a
lable
So I wrote
Partial Class ProductDetails
Inherits System.Web.UI.Page
Public test_bar As String
Protected Sub DataList1_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataListItemEventArgs) Handles
DataList1.ItemDataBound
' Highlight the product name and unit price Labels
' First, get a reference to the two Label Web controls
Dim PNL1 As Label = CType(e.Item.FindControl("Sub_typeIDLabel"), Label)
Dim PNL2 As Label = CType(e.Item.FindControl("Sub_typeNameLabel"), Label)
Dim PNL3 As Label = CType(e.Item.FindControl("Label1"), Label)
Dim PNL4 As Label = CType(e.Item.FindControl("BSPLabel"), Label)
Dim PNL5 As Label = CType(e.Item.FindControl("RequiredLabel"), Label)
Dim PNL6 As Label = CType(e.Item.FindControl("Product_DescriptionLabel"),
Label)
Dim PNL7 As Label = CType(e.Item.FindControl("AmountLabel"), Label)
Dim PNL8 As Label = CType(e.Item.FindControl("LabelColor"), Label)
Dim PNL9 As Label = CType(e.Item.FindControl("Labelvendor_Name"), Label)
Dim PNL10 As Label = CType(e.Item.FindControl("GNLabel"), Label)
Dim PNL11 As Label = CType(e.Item.FindControl("NotesLabel"), Label)
Dim ProductNameLabel As Label = CType(e.Item.FindControl("GNLabel"), Label)
Dim PNL12 As DropDownList = CType(e.Item.FindControl("DLColor"),
DropDownList)
' Next, set their CssClass properties
If ProductNameLabel IsNot Nothing Then
'ProductNameLabel.CssClass = "AffordablePriceEmphasis"
Me.Label2.Text = ProductNameLabel.Text
End If
If PNL1 IsNot Nothing Then
'either chr(9) or vbTab works
Me.lblData.Text = PNL2.Text + Chr(9) + PNL7.Text + vbTab + Chr(49) + vbTab +
PNL11.Text + vbTab + PNL8.Text + vbTab + Chr(49) + vbTab + "00090" + vbTab +
PNL12.Text
test_bar = Me.lblData.Text
End If
Everything was fine but my Color field has multiple colors so I created a
Dropdown list inside the Datalist control and it show all the colors with no
problems
But when I tried to read into my Label (lblData) it will not reed (PNL12) -
Dim PNL12 As DropDownList = CType(e.Item.FindControl("DLColor"),
DropDownList)
My question is how to read from Dropdown list into a label inside the
datalist?
It read the PNL8 but not the PNL12
Thanks,
Ed Dror
Andrew Lauren
I'm using asp.net 2.0 with SQL Server 2005
I created a datalist control and I would like to read the results into a
lable
So I wrote
Partial Class ProductDetails
Inherits System.Web.UI.Page
Public test_bar As String
Protected Sub DataList1_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataListItemEventArgs) Handles
DataList1.ItemDataBound
' Highlight the product name and unit price Labels
' First, get a reference to the two Label Web controls
Dim PNL1 As Label = CType(e.Item.FindControl("Sub_typeIDLabel"), Label)
Dim PNL2 As Label = CType(e.Item.FindControl("Sub_typeNameLabel"), Label)
Dim PNL3 As Label = CType(e.Item.FindControl("Label1"), Label)
Dim PNL4 As Label = CType(e.Item.FindControl("BSPLabel"), Label)
Dim PNL5 As Label = CType(e.Item.FindControl("RequiredLabel"), Label)
Dim PNL6 As Label = CType(e.Item.FindControl("Product_DescriptionLabel"),
Label)
Dim PNL7 As Label = CType(e.Item.FindControl("AmountLabel"), Label)
Dim PNL8 As Label = CType(e.Item.FindControl("LabelColor"), Label)
Dim PNL9 As Label = CType(e.Item.FindControl("Labelvendor_Name"), Label)
Dim PNL10 As Label = CType(e.Item.FindControl("GNLabel"), Label)
Dim PNL11 As Label = CType(e.Item.FindControl("NotesLabel"), Label)
Dim ProductNameLabel As Label = CType(e.Item.FindControl("GNLabel"), Label)
Dim PNL12 As DropDownList = CType(e.Item.FindControl("DLColor"),
DropDownList)
' Next, set their CssClass properties
If ProductNameLabel IsNot Nothing Then
'ProductNameLabel.CssClass = "AffordablePriceEmphasis"
Me.Label2.Text = ProductNameLabel.Text
End If
If PNL1 IsNot Nothing Then
'either chr(9) or vbTab works
Me.lblData.Text = PNL2.Text + Chr(9) + PNL7.Text + vbTab + Chr(49) + vbTab +
PNL11.Text + vbTab + PNL8.Text + vbTab + Chr(49) + vbTab + "00090" + vbTab +
PNL12.Text
test_bar = Me.lblData.Text
End If
Everything was fine but my Color field has multiple colors so I created a
Dropdown list inside the Datalist control and it show all the colors with no
problems
But when I tried to read into my Label (lblData) it will not reed (PNL12) -
Dim PNL12 As DropDownList = CType(e.Item.FindControl("DLColor"),
DropDownList)
My question is how to read from Dropdown list into a label inside the
datalist?
It read the PNL8 but not the PNL12
Thanks,
Ed Dror
Andrew Lauren