Hey everyone,
I have a wierd issue i can't seem to find out whats going on. I have a
Control for a Shopping Cart Merchant Page called OrderStatus.ascx Inside
that control there is a Repeater with the Products that were ordered on the
ItemCreated event of the repeater i set a property of an options control
within the repeater. The Options control sets a DropDownList and then sets
a SelectedValue.
The Selected Value prop is correct after set, when you get back to the
itemCreated sub it is set there as well, But when it gets out of the
DataBind function and back to the PageLoad sub this value is cleared. Any
idea why anyone?
Here is the code:
---------------------------------------
--
OrderStatus.aspx
--
<asp:repeater id="ProductsRepeater" runat="server">
<itemtemplate>
<tr bgcolor="#ffffff">
<td class="adminBlack" valign="top">
<input type="hidden" runat="server" id="ProductID"
value='<%#DataBinder.Eval(Container.DataItem, "ProductID")%>'>
<asp:textbox runat="server" id="txtQty" cssclass="formText"
text='<%#DataBinder.Eval(Container.DataItem, "Quantity")%>' width="30px">
</asp:textbox><br>
<asp:button runat="server" id="updateQty"
commandargument='<%#DataBinder.Eval(Container.Data Item, "ProductID")%>'
commandname="updateQty" text="Update" cssclass="submitButton">
</asp:button>
</td>
<td class="adminBlack"><a
href='http://www.mrchocolate.com/ecom/site/product.cfm?id=<%#DataBinder.Eval(Container.DataIt em,
"ProductID")%>'><%#DataBinder.Eval(Container.DataI tem, "Name")%></a>
<uc1:productoptionscontrol id="ProductOptionsControl1"
runat="server"></uc1:productoptionscontrol>
</td>
<td class="adminBlack" align="right"
valign="top"><%#String.Format("{0:c}", DataBinder.Eval(Container.DataItem,
"ItemPrice"))%></td>
<td class="adminBlack" align="right"
valign="top"><%#String.Format("{0:c}", DataBinder.Eval(Container.DataItem,
"ItemTotal"))%></td>
</tr>
</itemtemplate>
</asp:repeater>
--
OrderStatus.aspx.vb
--
--
Sub Page_Load:
--
Me.ProductsRepeater.DataSource = shipAddress.OrderItems
Me.ProductsRepeater.DataBind()
'SelectedValue is reset back to 29 here ??? WHY ???
--
Sub ProductsRepeater_ItemCreated:
--
ProductOptionsControl1 = e.Item.FindControl("ProductOptionsControl1")
If Not IsNothing(Me.ProductOptionsControl1.OrderItem) Then
Dim item As COrderItem = e.Item.DataItem
ProductOptionsControl1.OrderItem = item
'SelectedValue is valid at 27
End If
--
ProductOptionsControl.ascx.vb:
--
Private m_orderItem As COrderItem
Friend Property OrderItem() As COrderItem
Get
If IsNothing(m_orderItem) Then
m_orderItem = CType(Me.ViewState.Item("m_orderItem"), COrderItem)
End If
Return m_orderItem
End Get
Set(ByVal Value As COrderItem)
m_orderItem = Value
Me.ViewState.Add("m_orderItem", m_orderItem)
If IsNothing(m_orderItem) Then
m_orderItem.LoadOrderAttributes()
If Me.m_orderItem.Attributes.Count = 1 Then
Dim objProducts As New CStoreProducts
Dim arAttribs As ArrayList =
objProducts.GetProductAttributes(m_orderItem.Produ ctID)
Me.lblAttributeName.Text = CType(arAttribs(0), CAttribute).Name
Me.ddlAttributes.DataSource = CType(arAttribs(0),
CAttribute).AttributeDetails
Me.ddlAttributes.DataTextField = "Name_Price_Info"
Me.ddlAttributes.DataValueField = "UID"
Me.ddlAttributes.DataBind()
'Example DDL Values are 29,27,28
'Selected Value is set to 27
Me.ddlAttributes.SelectedValue = CType(CType(m_orderItem.Attributes(0),
CAttribute).AttributeDetails(0), CAttributeDetail).UID.ToString
'SelectedValue is valid at 27
Else
Me.Visible = False
End If
End If
End Set
End Property
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub 3 3293
It might be an issue with the ViewState. It doesn't seem to be saving. The
Controls EnableViewState=true, and also the Instance EnableViewState=true
Anyone?
On Fri, 28 Oct 2005 11:03:36 -0400, Ben Dewey wrote: Hey everyone,
I have a wierd issue i can't seem to find out whats going on. I have a Control for a Shopping Cart Merchant Page called OrderStatus.ascx Inside that control there is a Repeater with the Products that were ordered on the ItemCreated event of the repeater i set a property of an options control within the repeater. The Options control sets a DropDownList and then sets a SelectedValue.
The Selected Value prop is correct after set, when you get back to the itemCreated sub it is set there as well, But when it gets out of the DataBind function and back to the PageLoad sub this value is cleared. Any idea why anyone?
Here is the code: ---------------------------------------
-- OrderStatus.aspx -- <asp:repeater id="ProductsRepeater" runat="server"> <itemtemplate> <tr bgcolor="#ffffff"> <td class="adminBlack" valign="top"> <input type="hidden" runat="server" id="ProductID" value='<%#DataBinder.Eval(Container.DataItem, "ProductID")%>'> <asp:textbox runat="server" id="txtQty" cssclass="formText" text='<%#DataBinder.Eval(Container.DataItem, "Quantity")%>' width="30px"> </asp:textbox><br> <asp:button runat="server" id="updateQty" commandargument='<%#DataBinder.Eval(Container.Data Item, "ProductID")%>' commandname="updateQty" text="Update" cssclass="submitButton"> </asp:button> </td> <td class="adminBlack"><a href='http://www.mrchocolate.com/ecom/site/product.cfm?id=<%#DataBinder.Eval(Container.DataIt em, "ProductID")%>'><%#DataBinder.Eval(Container.DataI tem, "Name")%></a> <uc1:productoptionscontrol id="ProductOptionsControl1" runat="server"></uc1:productoptionscontrol> </td> <td class="adminBlack" align="right" valign="top"><%#String.Format("{0:c}", DataBinder.Eval(Container.DataItem, "ItemPrice"))%></td> <td class="adminBlack" align="right" valign="top"><%#String.Format("{0:c}", DataBinder.Eval(Container.DataItem, "ItemTotal"))%></td> </tr> </itemtemplate> </asp:repeater>
-- OrderStatus.aspx.vb -- -- Sub Page_Load: -- Me.ProductsRepeater.DataSource = shipAddress.OrderItems Me.ProductsRepeater.DataBind() 'SelectedValue is reset back to 29 here ??? WHY ???
-- Sub ProductsRepeater_ItemCreated: -- ProductOptionsControl1 = e.Item.FindControl("ProductOptionsControl1")
If Not IsNothing(Me.ProductOptionsControl1.OrderItem) Then Dim item As COrderItem = e.Item.DataItem
ProductOptionsControl1.OrderItem = item 'SelectedValue is valid at 27 End If
-- ProductOptionsControl.ascx.vb: -- Private m_orderItem As COrderItem Friend Property OrderItem() As COrderItem Get If IsNothing(m_orderItem) Then m_orderItem = CType(Me.ViewState.Item("m_orderItem"), COrderItem) End If Return m_orderItem End Get Set(ByVal Value As COrderItem) m_orderItem = Value Me.ViewState.Add("m_orderItem", m_orderItem)
If IsNothing(m_orderItem) Then m_orderItem.LoadOrderAttributes()
If Me.m_orderItem.Attributes.Count = 1 Then Dim objProducts As New CStoreProducts Dim arAttribs As ArrayList = objProducts.GetProductAttributes(m_orderItem.Produ ctID)
Me.lblAttributeName.Text = CType(arAttribs(0), CAttribute).Name
Me.ddlAttributes.DataSource = CType(arAttribs(0), CAttribute).AttributeDetails Me.ddlAttributes.DataTextField = "Name_Price_Info" Me.ddlAttributes.DataValueField = "UID" Me.ddlAttributes.DataBind()
'Example DDL Values are 29,27,28 'Selected Value is set to 27 Me.ddlAttributes.SelectedValue = CType(CType(m_orderItem.Attributes(0), CAttribute).AttributeDetails(0), CAttributeDetail).UID.ToString
'SelectedValue is valid at 27
Else Me.Visible = False End If End If End Set End Property
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here End Sub
Perhaps the problem is the postback behavior. you are rerendering
everything, everytime. Use the IsPostBack to control when you are
rebuilding the controls.
Well I figured out what the problem was. I was using the IsPostBack to
check and I wasn't rebinding the Repeater. The problem was that I was using
the OnItemCreated event for the repeater. I changed it to the
OnItemDataBound Event.
When I used the OnItemCreated event it Rebound the Nested Repeater on
everypost back
Essentially if you use nested repeaters and you are having an issue saving
the state. It probably a rebinding issue. Make sure you are checking the
IsPostBack and only Binding Once. Also make sure you are binding your
nested repeaters/controls on the OnDataBound Event, not the OnItemCreated
Event. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: kamaumalone |
last post by:
I have a dropdownlist which lives inside of a repeater. The repeater
accepts user input via textboxes and the aforementioned dropdownlist.
The repeater accepts phone numbers and allows for an...
|
by: mrwoopey |
last post by:
I did not find code for adding an event to dropdownlist in a repeater
control posted anywhere. So, I am posting it for the next person
(sorry if this seems obvious to you):
''''''''''''''''''''...
|
by: Shaun Camilleri |
last post by:
Hi all,
I am creating a DropDownList in a RepeaterControl. After the Repeater is
DataBound in the ItemCreated event (of the Repeater) I bind the DropDownList
to a Table and then try to select one...
|
by: charliewest |
last post by:
Hello -
I'm using a Repeater control to render information in a very customized
grid-like table. The Repeater control is binded to a DataSet with several
records of information. Within the...
|
by: Jeremy |
last post by:
Hello All,
I have a Repeater which contains a Dynamic DropDownList within its
itemtemplate. I know I have struggled with this before and I am pretty sure I
had to save a bunch of crap manually...
|
by: mwhitlatch |
last post by:
I have a repeater where the data is filtered by a param in the querystring. In the repeater I have a dropdown that needs to only show the data based upon the filter I set up in the datasource. I have...
|
by: Nitinkcv |
last post by:
Hi,
i have my button actually inside a repeater and it validates info from textboxes and ddl inside the repeater.. The prob is that i have "SELECT VALUE" chosen as the default value in my ddl. so...
|
by: Mahathi |
last post by:
Hi
I have a small problem in maintaining the state of a check box. Please do me a favour by telling me the procedure how to do that.
My requirement is that
"I have to map some roles with...
|
by: Ben |
last post by:
Hi,
i dynamically feed a dropdownlist which value from 1 to 20. That
dropdownlist is bound to field 'wa' (type nvarchar(4)) in 'mytable'. There
are 4 records and the values of field 'wa' are: 2...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |