custom control bindable property

Discussion in 'ASP .Net Building Controls' started by MrB, Dec 29, 2003.

  1. MrB

    MrB Guest

    I've made a server control that overrides the dropdownlist control. It has
    one new property (ddlLocation) that needs to be databound. All is working
    well if I type the databound information into the asp.net html view. see
    example below.

    <jb:jbddl id=jbddl_court_id runat="server" Width="152px"
    DataValueField="court_id" DataTextField="court" svrReadOnly="False"
    DataSource='<%# objCase.getCourts() %>' ddlLocation='<%# objCase("Location")
    %>'> </jb:jbddl>



    However I would like the user to be able to type the databinding information
    (objCase("Location")) for the ddlLocation property into the visual studio
    property window - the way the datasource property works. when i do that
    though, the control does not resolve the objCase("Location") to a number, it
    just receives the string 'objCase("Location")'.

    Here is the relevant server control code.

    <Category("Data"), Bindable(True)> Public Property ddlLocation() as String

    Get
    Return strddlLocation
    End Get

    Set(ByVal Value As String)
    strddlLocation = Value
    End Set

    End Property

    What do i need to do to make the ddlLocation property act the way the
    datasource property does in the vs property window?

    Thanks in advance,

    Jim
    MrB, Dec 29, 2003
    #1
    1. Advertising

  2. hi jim,
    if you looking for a dropdown list with DataValue fields for the selected
    dataSource when clicking on your ddlLocation property in the PropertyGrid
    then you might want to read this article. The code is c# but you shouldnt
    have a problem converting it to vb.net --that articles goes into all the
    details.
    http://www.codeproject.com/aspnet/webcontrolsdatabinding.asp

    Here is a short explaination you can find on
    MSDN --http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgu
    ide/html/cpconimplementingdataboundcontroldesingerwebforms.asp


    "MrB" <> wrote in message
    news:...
    > I've made a server control that overrides the dropdownlist control. It

    has
    > one new property (ddlLocation) that needs to be databound. All is working
    > well if I type the databound information into the asp.net html view. see
    > example below.
    >
    > <jb:jbddl id=jbddl_court_id runat="server" Width="152px"
    > DataValueField="court_id" DataTextField="court" svrReadOnly="False"
    > DataSource='<%# objCase.getCourts() %>' ddlLocation='<%#

    objCase("Location")
    > %>'> </jb:jbddl>
    >
    >
    >
    > However I would like the user to be able to type the databinding

    information
    > (objCase("Location")) for the ddlLocation property into the visual studio
    > property window - the way the datasource property works. when i do that
    > though, the control does not resolve the objCase("Location") to a number,

    it
    > just receives the string 'objCase("Location")'.
    >
    > Here is the relevant server control code.
    >
    > <Category("Data"), Bindable(True)> Public Property ddlLocation() as String
    >
    > Get
    > Return strddlLocation
    > End Get
    >
    > Set(ByVal Value As String)
    > strddlLocation = Value
    > End Set
    >
    > End Property
    >
    > What do i need to do to make the ddlLocation property act the way the
    > datasource property does in the vs property window?
    >
    > Thanks in advance,
    >
    > Jim
    >
    >
    Alessandro Zifiglio, Dec 30, 2003
    #2
    1. Advertising

  3. MrB

    MrB Guest

    Thanks, I'll take a look at that article.
    Jim
    MrB, Dec 31, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tommy

    create a bindable property

    Tommy, Nov 4, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    2,609
    Tommy
    Nov 4, 2004
  2. Steve
    Replies:
    1
    Views:
    566
    Steve
    Sep 30, 2006
  3. MrB

    server control simple bindable property

    MrB, Dec 23, 2003, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    145
  4. Tommy

    bindable property to extend the textbox

    Tommy, Nov 5, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    136
    Tommy
    Nov 5, 2004
  5. Craig Buchanan
    Replies:
    0
    Views:
    162
    Craig Buchanan
    Aug 22, 2007
Loading...

Share This Page