user control and databinding expression

G

Guest

hey all,
for simplicity's sake i have a single textbox inside a user control. once i
drag that user control onto my page is there a way to attach a binding
expression to it at runtime?

thanks,
rodchar
 
E

Eliyahu Goldin

User control can expose properties. You can make a property that will set
the binding expression. Is it what you are after?
 
G

Guest

yes, i've exposed public properties in a user control but which one do i
expose in this case. i couldn't find the DataBindings.Add for the textbox in
my user control (with the context of being in the user control designer).

i guess what i'm asking is what public property do i expose on the user
control and how do i set it?

thanks,
rodchar

Eliyahu Goldin said:
User control can expose properties. You can make a property that will set
the binding expression. Is it what you are after?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


rodchar said:
hey all,
for simplicity's sake i have a single textbox inside a user control. once
i
drag that user control onto my page is there a way to attach a binding
expression to it at runtime?

thanks,
rodchar
 
E

Eliyahu Goldin

Something like this?

public string TextBinding
{
set
{
myText.Text = value;
myText.DataBind();
}
}

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


rodchar said:
yes, i've exposed public properties in a user control but which one do i
expose in this case. i couldn't find the DataBindings.Add for the textbox
in
my user control (with the context of being in the user control designer).

i guess what i'm asking is what public property do i expose on the user
control and how do i set it?

thanks,
rodchar

Eliyahu Goldin said:
User control can expose properties. You can make a property that will set
the binding expression. Is it what you are after?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


rodchar said:
hey all,
for simplicity's sake i have a single textbox inside a user control.
once
i
drag that user control onto my page is there a way to attach a binding
expression to it at runtime?

thanks,
rodchar
 
G

Guest

I'm not sure what i'm doing wrong:

<uc1:webusercontrol id="WebUserControl1" runat="server" uctextbox='<%#
"GetTime()" %>'></uc1:webusercontrol>

defined on the .aspx:
Public Function GetTime() As String
Return DateTime.Now.ToString("T")
End Function

defined on the control page:
Public Property UcTextBox() As String
Get
Return Me.TextBox1.Text
End Get
Set(ByVal value As String)
Me.TextBox1.Text = value
End Set
End Property

And the result is that nothing shows up in the textbox.

Eliyahu Goldin said:
Something like this?

public string TextBinding
{
set
{
myText.Text = value;
myText.DataBind();
}
}

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


rodchar said:
yes, i've exposed public properties in a user control but which one do i
expose in this case. i couldn't find the DataBindings.Add for the textbox
in
my user control (with the context of being in the user control designer).

i guess what i'm asking is what public property do i expose on the user
control and how do i set it?

thanks,
rodchar

Eliyahu Goldin said:
User control can expose properties. You can make a property that will set
the binding expression. Is it what you are after?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


hey all,
for simplicity's sake i have a single textbox inside a user control.
once
i
drag that user control onto my page is there a way to attach a binding
expression to it at runtime?

thanks,
rodchar
 
E

Eliyahu Goldin

call DataBind()

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


rodchar said:
I'm not sure what i'm doing wrong:

<uc1:webusercontrol id="WebUserControl1" runat="server" uctextbox='<%#
"GetTime()" %>'></uc1:webusercontrol>

defined on the .aspx:
Public Function GetTime() As String
Return DateTime.Now.ToString("T")
End Function

defined on the control page:
Public Property UcTextBox() As String
Get
Return Me.TextBox1.Text
End Get
Set(ByVal value As String)
Me.TextBox1.Text = value
End Set
End Property

And the result is that nothing shows up in the textbox.

Eliyahu Goldin said:
Something like this?

public string TextBinding
{
set
{
myText.Text = value;
myText.DataBind();
}
}

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


rodchar said:
yes, i've exposed public properties in a user control but which one do
i
expose in this case. i couldn't find the DataBindings.Add for the
textbox
in
my user control (with the context of being in the user control
designer).

i guess what i'm asking is what public property do i expose on the user
control and how do i set it?

thanks,
rodchar

:

User control can expose properties. You can make a property that will
set
the binding expression. Is it what you are after?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


hey all,
for simplicity's sake i have a single textbox inside a user control.
once
i
drag that user control onto my page is there a way to attach a
binding
expression to it at runtime?

thanks,
rodchar
 
G

Guest

sorry for just not getting it, but where do i from? (control page in the
properties, on on the .aspx page) i tried in both places and i'm not getting
anything?

Eliyahu Goldin said:
call DataBind()

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


rodchar said:
I'm not sure what i'm doing wrong:

<uc1:webusercontrol id="WebUserControl1" runat="server" uctextbox='<%#
"GetTime()" %>'></uc1:webusercontrol>

defined on the .aspx:
Public Function GetTime() As String
Return DateTime.Now.ToString("T")
End Function

defined on the control page:
Public Property UcTextBox() As String
Get
Return Me.TextBox1.Text
End Get
Set(ByVal value As String)
Me.TextBox1.Text = value
End Set
End Property

And the result is that nothing shows up in the textbox.

Eliyahu Goldin said:
Something like this?

public string TextBinding
{
set
{
myText.Text = value;
myText.DataBind();
}
}

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


yes, i've exposed public properties in a user control but which one do
i
expose in this case. i couldn't find the DataBindings.Add for the
textbox
in
my user control (with the context of being in the user control
designer).

i guess what i'm asking is what public property do i expose on the user
control and how do i set it?

thanks,
rodchar

:

User control can expose properties. You can make a property that will
set
the binding expression. Is it what you are after?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


hey all,
for simplicity's sake i have a single textbox inside a user control.
once
i
drag that user control onto my page is there a way to attach a
binding
expression to it at runtime?

thanks,
rodchar
 
G

Guest

ok i tried the databinding with a real datasource instead of the function and
it worked. out of curiosity, is the function suppose to work and maybe my
declaring syntax is incorrect?


rodchar said:
sorry for just not getting it, but where do i from? (control page in the
properties, on on the .aspx page) i tried in both places and i'm not getting
anything?

Eliyahu Goldin said:
call DataBind()

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


rodchar said:
I'm not sure what i'm doing wrong:

<uc1:webusercontrol id="WebUserControl1" runat="server" uctextbox='<%#
"GetTime()" %>'></uc1:webusercontrol>

defined on the .aspx:
Public Function GetTime() As String
Return DateTime.Now.ToString("T")
End Function

defined on the control page:
Public Property UcTextBox() As String
Get
Return Me.TextBox1.Text
End Get
Set(ByVal value As String)
Me.TextBox1.Text = value
End Set
End Property

And the result is that nothing shows up in the textbox.

:

Something like this?

public string TextBinding
{
set
{
myText.Text = value;
myText.DataBind();
}
}

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


yes, i've exposed public properties in a user control but which one do
i
expose in this case. i couldn't find the DataBindings.Add for the
textbox
in
my user control (with the context of being in the user control
designer).

i guess what i'm asking is what public property do i expose on the user
control and how do i set it?

thanks,
rodchar

:

User control can expose properties. You can make a property that will
set
the binding expression. Is it what you are after?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


hey all,
for simplicity's sake i have a single textbox inside a user control.
once
i
drag that user control onto my page is there a way to attach a
binding
expression to it at runtime?

thanks,
rodchar
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top