usercontrol initialization question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Florian Paulus

    usercontrol initialization question

    hallo group!

    i have a user control that using a listbox and a dataset to fill it.

    usually i can give some parameters in the form of public properties to
    user controls for example :

    <my:MinMaxAlpha Field Required="false " ID="cfCity" Label="City:"
    MaxCharacters=" 50" MinCharacters=" 3" runat="server"/>

    so here im setting the label text and it works fine.

    now for the usercontrol that has the listbox i want to pass the dataset.

    unfortunately i seem to be able to just pass strings there so my
    question is, how can i pass a dataset from outside?

    the dataset itself is the result of a methodcall.

    the page containing all this is using a wizard control and the data
    depends on a wizard step before, so i tried to pass the dataset in the
    wizardstep event, but this assignment seems to be done after the control
    is rendered, cause if i set a breakpoint in the control's page_load
    event where the dataset is assigned to the listbox its still null.

    how can i accomplish my mission? i hope its understandable.

    cheers

    florian
  • =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=

    #2
    RE: usercontrol initialization question

    Good evening,

    1. Programatic data binding:
    Add new property called i.e. MyListDataSourc e and a method:

    public object MyListDataSourc e
    {
    get
    {
    return myListBox.DataS ource;
    }
    set
    {
    myListBox.DataS ource = value;
    }
    }

    public void MyListDataBind( )
    {
    myListBox.DataB ind();
    }

    finally, in code behind of the page you placed your control:

    cfCity.DataSour ce = myDataSet;
    cfCity.DataBind ();

    2. Declarative data binding.
    If you are planning to use any of the data source control (SqlDataSource,
    ObjectDataSourc e, etc) add one additional property:

    public string MyListDataSourc eID
    {
    get
    {
    return myListBox.DataS ourceID;
    }
    set
    {
    myListBox.DataS ourceID = value;
    }
    }

    <my:MinMaxAlpha Field Required="false " ID="cfCity" Label="City:"
    MaxCharacters=" 50" MinCharacters=" 3" runat="server"
    MyListDataSourc eID="mySqlDataS ource" />

    I would implement both options to give user control users a choice.

    Hope this helps
    --
    Milosz


    "Florian Paulus" wrote:
    hallo group!
    >
    i have a user control that using a listbox and a dataset to fill it.
    >
    usually i can give some parameters in the form of public properties to
    user controls for example :
    >
    <my:MinMaxAlpha Field Required="false " ID="cfCity" Label="City:"
    MaxCharacters=" 50" MinCharacters=" 3" runat="server"/>
    >
    so here im setting the label text and it works fine.
    >
    now for the usercontrol that has the listbox i want to pass the dataset.
    >
    unfortunately i seem to be able to just pass strings there so my
    question is, how can i pass a dataset from outside?
    >
    the dataset itself is the result of a methodcall.
    >
    the page containing all this is using a wizard control and the data
    depends on a wizard step before, so i tried to pass the dataset in the
    wizardstep event, but this assignment seems to be done after the control
    is rendered, cause if i set a breakpoint in the control's page_load
    event where the dataset is assigned to the listbox its still null.
    >
    how can i accomplish my mission? i hope its understandable.
    >
    cheers
    >
    florian
    >

    Comment

    Working...