HighTechTalks DotNet Forums  

Creating a reusable dropdownlist for use in formview

ASP.net Building Controls microsoft.public.dotnet.framework.aspnet.buildingcontrols


Discuss Creating a reusable dropdownlist for use in formview in the ASP.net Building Controls forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Rodrigo Juarez
 
Posts: n/a

Default Creating a reusable dropdownlist for use in formview - 02-24-2006 , 10:32 PM






Hi

I need to create a dropdownlist for reusing in a lot of formviews, with
databinding.

If I create a user control the selectedvalue is not usable for databinding
in formview.

Thanks in advance



Reply With Quote
  #2  
Old   
Teemu Keiski
 
Posts: n/a

Default Re: Creating a reusable dropdownlist for use in formview - 02-26-2006 , 12:53 AM






Hi,

if you create a User Control, you can expose the SelectedValue and other
properties of the DroPDownList from the user control. You can for example
just create another property on the UC. Assuming you already have a
DropDownList with ID "DropDownList1" in the user control, you could have a
property as follows:

public string DdlSelectedValue
{
get
{
return DropDownList1.SelectedValue;
}
set
{
DropDownList1.SelectedValue = value;
}
}

to expose the DDL's SelectedValue.

If you need more from the DDL, you can expose more properties or even the
DropDOwnList itself entirely with a read-only property.


public DropDownList InnerDDL
{
get
{
return DropDownList1;
}
}


--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke


"Rodrigo Juarez" <rodrigoj (AT) azinformatica (DOT) com.ar> wrote

Quote:
Hi

I need to create a dropdownlist for reusing in a lot of formviews, with
databinding.

If I create a user control the selectedvalue is not usable for databinding
in formview.

Thanks in advance





Reply With Quote
  #3  
Old   
Rodrigo Juarez
 
Posts: n/a

Default Re: Creating a reusable dropdownlist for use in formview - 02-26-2006 , 09:13 PM



Thanks for your reply.

Here is the content of ascx file for my user control

<%@ Control Language="VB" AutoEventWireup="false"
CodeFile="tipocuenta.ascx.vb" Inherits="tipocuenta" %>

<script runat="server">

Public Property TipoCuentaSel() As String

Get

Return ddlTipoCuenta.SelectedValue

End Get

Set(ByVal value As String)

ddlTipoCuenta.SelectedValue = value

End Set

End Property

</script>

<aspropDownList ID="ddlTipoCuenta" runat="server">

<asp:ListItem Value="2">Cuenta Corriente</asp:ListItem>

<asp:ListItem Value="3">Caja de Ahorro</asp:ListItem>

</aspropDownList>



I'm using the control in the insert template in a form view, but the
property TipoCuentaSel() is not available for databinding ...

What can I do?

TIA

Rodrigo Juarez



"Teemu Keiski" <joteke (AT) aspalliance (DOT) com> escribió en el mensaje
news:eRjnNFqOGHA.3840 (AT) TK2MSFTNGP14 (DOT) phx.gbl...
Quote:
Hi,

if you create a User Control, you can expose the SelectedValue and other
properties of the DroPDownList from the user control. You can for example
just create another property on the UC. Assuming you already have a
DropDownList with ID "DropDownList1" in the user control, you could have a
property as follows:

public string DdlSelectedValue
{
get
{
return DropDownList1.SelectedValue;
}
set
{
DropDownList1.SelectedValue = value;
}
}

to expose the DDL's SelectedValue.

If you need more from the DDL, you can expose more properties or even the
DropDOwnList itself entirely with a read-only property.


public DropDownList InnerDDL
{
get
{
return DropDownList1;
}
}


--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke


"Rodrigo Juarez" <rodrigoj (AT) azinformatica (DOT) com.ar> wrote in message
news:ed6OLUcOGHA.1676 (AT) TK2MSFTNGP09 (DOT) phx.gbl...
Hi

I need to create a dropdownlist for reusing in a lot of formviews, with
databinding.

If I create a user control the selectedvalue is not usable for
databinding
in formview.

Thanks in advance








Reply With Quote
  #4  
Old   
Teemu Keiski
 
Posts: n/a

Default Re: Creating a reusable dropdownlist for use in formview - 02-27-2006 , 10:27 AM



Hi,

post also the FormView code. Do you get any specific error msg?`

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

"Rodrigo Juarez" <rodrigoj (AT) azinformatica (DOT) com.ar> wrote

Quote:
Thanks for your reply.

Here is the content of ascx file for my user control

%@ Control Language="VB" AutoEventWireup="false"
CodeFile="tipocuenta.ascx.vb" Inherits="tipocuenta" %

script runat="server"

Public Property TipoCuentaSel() As String

Get

Return ddlTipoCuenta.SelectedValue

End Get

Set(ByVal value As String)

ddlTipoCuenta.SelectedValue = value

End Set

End Property

/script

aspropDownList ID="ddlTipoCuenta" runat="server"

asp:ListItem Value="2">Cuenta Corriente</asp:ListItem

asp:ListItem Value="3">Caja de Ahorro</asp:ListItem

/aspropDownList



I'm using the control in the insert template in a form view, but the
property TipoCuentaSel() is not available for databinding ...

What can I do?

TIA

Rodrigo Juarez



"Teemu Keiski" <joteke (AT) aspalliance (DOT) com> escribió en el mensaje
news:eRjnNFqOGHA.3840 (AT) TK2MSFTNGP14 (DOT) phx.gbl...
Hi,

if you create a User Control, you can expose the SelectedValue and other
properties of the DroPDownList from the user control. You can for example
just create another property on the UC. Assuming you already have a
DropDownList with ID "DropDownList1" in the user control, you could have
a
property as follows:

public string DdlSelectedValue
{
get
{
return DropDownList1.SelectedValue;
}
set
{
DropDownList1.SelectedValue = value;
}
}

to expose the DDL's SelectedValue.

If you need more from the DDL, you can expose more properties or even the
DropDOwnList itself entirely with a read-only property.


public DropDownList InnerDDL
{
get
{
return DropDownList1;
}
}


--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke


"Rodrigo Juarez" <rodrigoj (AT) azinformatica (DOT) com.ar> wrote in message
news:ed6OLUcOGHA.1676 (AT) TK2MSFTNGP09 (DOT) phx.gbl...
Hi

I need to create a dropdownlist for reusing in a lot of formviews, with
databinding.

If I create a user control the selectedvalue is not usable for
databinding
in formview.

Thanks in advance










Reply With Quote
  #5  
Old   
Rodrigo Juarez
 
Posts: n/a

Default Re: Creating a reusable dropdownlist for use in formview - 03-02-2006 , 09:49 AM



No erro, the problem is I can't bind data with smart tag options, but I code
the control and works fine.
Thanks for your help

"Teemu Keiski" <joteke (AT) aspalliance (DOT) com> escribió en el mensaje
news:O4wNAr7OGHA.3984 (AT) TK2MSFTNGP14 (DOT) phx.gbl...
Quote:
Hi,

post also the FormView code. Do you get any specific error msg?`

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

"Rodrigo Juarez" <rodrigoj (AT) azinformatica (DOT) com.ar> wrote in message
news:e$J7Hv0OGHA.3936 (AT) TK2MSFTNGP12 (DOT) phx.gbl...
Thanks for your reply.

Here is the content of ascx file for my user control

%@ Control Language="VB" AutoEventWireup="false"
CodeFile="tipocuenta.ascx.vb" Inherits="tipocuenta" %

script runat="server"

Public Property TipoCuentaSel() As String

Get

Return ddlTipoCuenta.SelectedValue

End Get

Set(ByVal value As String)

ddlTipoCuenta.SelectedValue = value

End Set

End Property

/script

aspropDownList ID="ddlTipoCuenta" runat="server"

asp:ListItem Value="2">Cuenta Corriente</asp:ListItem

asp:ListItem Value="3">Caja de Ahorro</asp:ListItem

/aspropDownList



I'm using the control in the insert template in a form view, but the
property TipoCuentaSel() is not available for databinding ...

What can I do?

TIA

Rodrigo Juarez



"Teemu Keiski" <joteke (AT) aspalliance (DOT) com> escribió en el mensaje
news:eRjnNFqOGHA.3840 (AT) TK2MSFTNGP14 (DOT) phx.gbl...
Hi,

if you create a User Control, you can expose the SelectedValue and
other
properties of the DroPDownList from the user control. You can for
example
just create another property on the UC. Assuming you already have a
DropDownList with ID "DropDownList1" in the user control, you could
have
a
property as follows:

public string DdlSelectedValue
{
get
{
return DropDownList1.SelectedValue;
}
set
{
DropDownList1.SelectedValue = value;
}
}

to expose the DDL's SelectedValue.

If you need more from the DDL, you can expose more properties or even
the
DropDOwnList itself entirely with a read-only property.


public DropDownList InnerDDL
{
get
{
return DropDownList1;
}
}


--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke


"Rodrigo Juarez" <rodrigoj (AT) azinformatica (DOT) com.ar> wrote in message
news:ed6OLUcOGHA.1676 (AT) TK2MSFTNGP09 (DOT) phx.gbl...
Hi

I need to create a dropdownlist for reusing in a lot of formviews,
with
databinding.

If I create a user control the selectedvalue is not usable for
databinding
in formview.

Thanks in advance












Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.