Repeater + Extended control not working

Alright this is in my aspx file in the ItemTemplate section of the repeater

<td><cwc:DataDropDownList runat="server" DataSourceID="rolesDataSource" SelectedValue=<%# Eval("Role") %>
DataTextField="Description" DataValueField="id" AutoPostBack=true OnSelectedIndexChanged=dropDownList_SelectedIndexChanged
ExtraData=<%# Eval("FirstName") %> >
</cwc:DataDropDownList></td>

And this is what the code for the DataDropDownList looks like:

namespace CustomWebControls
{
[ToolboxData("<{0}:DataDropDownList runat=server></{0}:DataDropDownList>")]
public class DataDropDownList : System.Web.UI.WebControls.DropDownList
{
string extraData;

[BindableAttribute(true, BindingDirection.TwoWay)]
public virtual string ExtraData
{
get
{
return extraData;
}
set
{
extraData = value;
}
}
}
}

If I set the ExtraData to be something like "wtf" in the aspx then in the drop down's postback it shows up fine. If I leave it at the <%# Eval("FirstName") %> the value ends up being null. And I eval that same item elsewhere and it works fine, so I know it's not a spelling mistake.


Answer this question

Repeater + Extended control not working

  • IraW

    Alright, Well I managed to figure out my problem, for all those unaware. You need to store the property value in the viewstate instead of as a member value.

    so the property code now looks like this:

    public virtual string ExtraData
    {
    get { return ViewState["ExtraData"]; }
    set { ViewState["ExtraData"] = value; }
    }



  • Joao Talles

    I added some debug stuff, the Eval is getting called correctly the first time around, just not on the postback after I select a new drop down list item.



  • cis_student

    Ok, I just looked up what control state is... It looks interesting however what do you gain by using it



  • JamesCandy

    Good to see that you corrected by yourself using view state. Try the same thing with the control state.

    Regards,
    Jimmy



  • erickson777

    Anything you store in the control state remains there until it is explicitly removed. A web page developer can disable view state for the page however control state cannot be disabled.

    Regards,
    Jimmy



  • Repeater + Extended control not working