![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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 |
#3
| |||
| |||
|
|
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 |
#4
| |||
| |||
|
|
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 asp ropDownList ID="ddlTipoCuenta" runat="server"asp:ListItem Value="2">Cuenta Corriente</asp:ListItem asp:ListItem Value="3">Caja de Ahorro</asp:ListItem /asp ropDownListI'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 |
#5
| |||
| |||
|
|
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 asp ropDownList ID="ddlTipoCuenta" runat="server"asp:ListItem Value="2">Cuenta Corriente</asp:ListItem asp:ListItem Value="3">Caja de Ahorro</asp:ListItem /asp ropDownListI'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 |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |