473,503 Members | 3,247 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Repeater LinkButton

I've added a LinkButton to a repeater control and I set the link button as
follows:

<asp:LinkButton ID="DLLinkButton" CommandArgument='<%#
DataBinder.Eval(Container.DataItem, "DownloadID")%>' Runat=server
CommandName="DLCount" >Download Now!</asp:LinkButton>

When I click this button it dosen't do anything instead of calling the
function I created.

BTW, is this the best way to go about calling the function? I tried putting
in the onClick command the following:

OnClick='<% DLCount(DataBinder.Eval(Container.DataItem, "DownloadID"))%>'

But that didn't work. Any Ideas?
Nov 18 '05 #1
5 5421
How are you raising the event? You should be hooking into the repeater's
OnITemCommand event...not the linkbutton's click event..

Karl

"UnknownServices" <Un*************@discussions.microsoft.com> wrote in
message news:51**********************************@microsof t.com...
I've added a LinkButton to a repeater control and I set the link button as
follows:

<asp:LinkButton ID="DLLinkButton" CommandArgument='<%#
DataBinder.Eval(Container.DataItem, "DownloadID")%>' Runat=server
CommandName="DLCount" >Download Now!</asp:LinkButton>

When I click this button it dosen't do anything instead of calling the
function I created.

BTW, is this the best way to go about calling the function? I tried putting in the onClick command the following:

OnClick='<% DLCount(DataBinder.Eval(Container.DataItem, "DownloadID"))%>'

But that didn't work. Any Ideas?

Nov 18 '05 #2
I'm not sure what you mean by database control, but if you want to access
something that's in a user control from the main page, that isn't too hard.

Since you haven't given too much information, I see two possibilities: Your
user control is either static or dynamic. In both cases its just a matter
of setting the information you want public, or the methods you want to be
able to call to public.

public class myControl
inherits UserControl

private _isLoaded as boolean = tru
public readonly property IsLoaded() as boolean
get
return _isLoaded
end get
end property
....
public sub DoSomething()
End Sub
...
end class
from webform1, you are loading the control like:
<mytag:myControl id="mine" runat="server" />

you can simply access mine.IsLoaded or mine.DoSomething

If you are dynamically loading the control, like:

Dim c as Control = Page.LoadControl("MyControl.ascx")
somePlaceholder.Controls.add(c)

you simply need to properly cast the control -->
Dim c as MyControl= ctype(Page.LoadControl("MyControl.ascx"), MyControl)
dim controlLoaded as boolean = c.IsLoaded
c.DoSomething
somePlaceholder.Controls.add(c)

Hope this Helps
Karl

"Unknown-Services" <Un**************@discussions.microsoft.com> wrote in
message news:98**********************************@microsof t.com...
Ok that worked. Now I have another problem.
I have database controls in my user control and I want to access them from
my WebForm1.aspx. I found this on the net but I can't seem to figure out
where to put the code. I"m not even sure if this will help me out with my
problem

http://www.devx.com/vb2themax/Tip/18843

"Karl" wrote:
How are you raising the event? You should be hooking into the repeater's OnITemCommand event...not the linkbutton's click event..

Karl

"UnknownServices" <Un*************@discussions.microsoft.com> wrote in
message news:51**********************************@microsof t.com...
I've added a LinkButton to a repeater control and I set the link button as follows:

<asp:LinkButton ID="DLLinkButton" CommandArgument='<%#
DataBinder.Eval(Container.DataItem, "DownloadID")%>' Runat=server
CommandName="DLCount" >Download Now!</asp:LinkButton>

When I click this button it dosen't do anything instead of calling the
function I created.

BTW, is this the best way to go about calling the function? I tried

putting
in the onClick command the following:

OnClick='<% DLCount(DataBinder.Eval(Container.DataItem, "DownloadID"))%>'
But that didn't work. Any Ideas?


Nov 18 '05 #3
Hmm.. I really couldn't understand your post very well. May you please
reexplain it?

In my User Control (.ascx file) I have a DataSet, DataConnection etc. that
are all set to public and are created through VS.NET's designer. I'm trying
to access them from a regular page (. aspx file) so I can run some code
using them.. Hope this explains more of what I need.

"Karl" wrote:
I'm not sure what you mean by database control, but if you want to access
something that's in a user control from the main page, that isn't too hard.

Since you haven't given too much information, I see two possibilities: Your
user control is either static or dynamic. In both cases its just a matter
of setting the information you want public, or the methods you want to be
able to call to public.

public class myControl
inherits UserControl

private _isLoaded as boolean = tru
public readonly property IsLoaded() as boolean
get
return _isLoaded
end get
end property
....
public sub DoSomething()
End Sub
...
end class
from webform1, you are loading the control like:
<mytag:myControl id="mine" runat="server" />

you can simply access mine.IsLoaded or mine.DoSomething

If you are dynamically loading the control, like:

Dim c as Control = Page.LoadControl("MyControl.ascx")
somePlaceholder.Controls.add(c)

you simply need to properly cast the control -->
Dim c as MyControl= ctype(Page.LoadControl("MyControl.ascx"), MyControl)
dim controlLoaded as boolean = c.IsLoaded
c.DoSomething
somePlaceholder.Controls.add(c)

Hope this Helps
Karl

"Unknown-Services" <Un**************@discussions.microsoft.com> wrote in
message news:98**********************************@microsof t.com...
Ok that worked. Now I have another problem.
I have database controls in my user control and I want to access them from
my WebForm1.aspx. I found this on the net but I can't seem to figure out
where to put the code. I"m not even sure if this will help me out with my
problem

http://www.devx.com/vb2themax/Tip/18843

"Karl" wrote:
How are you raising the event? You should be hooking into the repeater's OnITemCommand event...not the linkbutton's click event..

Karl

"UnknownServices" <Un*************@discussions.microsoft.com> wrote in
message news:51**********************************@microsof t.com...
> I've added a LinkButton to a repeater control and I set the link button as > follows:
>
> <asp:LinkButton ID="DLLinkButton" CommandArgument='<%#
> DataBinder.Eval(Container.DataItem, "DownloadID")%>' Runat=server
> CommandName="DLCount" >Download Now!</asp:LinkButton>
>
> When I click this button it dosen't do anything instead of calling the
> function I created.
>
> BTW, is this the best way to go about calling the function? I tried
putting
> in the onClick command the following:
>
> OnClick='<% DLCount(DataBinder.Eval(Container.DataItem, "DownloadID"))%>' >
> But that didn't work. Any Ideas?


Nov 18 '05 #4
How are you including this User Control on your main page? If you aren't,
then you shouldn't be using a UserControl, but instead should just be
creating a plain class. Did yo drag and drop your user control on your aspx
file? Does your User Control do anything visual or is it just business
logic (connect to DB, return dataset?). The explanation bellow assums you
are including the user control in your page for some type of visual
stuff...which is why you use a user control. Your follow up posts makes me
think maybe you just want a normal class (.vb).

Please let me know :)

Karl

"Unknown-Services" <Un*************@discussions.microsoft.com> wrote in
message news:CA**********************************@microsof t.com...
Hmm.. I really couldn't understand your post very well. May you please
reexplain it?

In my User Control (.ascx file) I have a DataSet, DataConnection etc. that
are all set to public and are created through VS.NET's designer. I'm trying to access them from a regular page (. aspx file) so I can run some code
using them.. Hope this explains more of what I need.

"Karl" wrote:
I'm not sure what you mean by database control, but if you want to access something that's in a user control from the main page, that isn't too hard.
Since you haven't given too much information, I see two possibilities: Your user control is either static or dynamic. In both cases its just a matter of setting the information you want public, or the methods you want to be able to call to public.

public class myControl
inherits UserControl

private _isLoaded as boolean = tru
public readonly property IsLoaded() as boolean
get
return _isLoaded
end get
end property
....
public sub DoSomething()
End Sub
...
end class
from webform1, you are loading the control like:
<mytag:myControl id="mine" runat="server" />

you can simply access mine.IsLoaded or mine.DoSomething

If you are dynamically loading the control, like:

Dim c as Control = Page.LoadControl("MyControl.ascx")
somePlaceholder.Controls.add(c)

you simply need to properly cast the control -->
Dim c as MyControl= ctype(Page.LoadControl("MyControl.ascx"), MyControl)
dim controlLoaded as boolean = c.IsLoaded
c.DoSomething
somePlaceholder.Controls.add(c)

Hope this Helps
Karl

"Unknown-Services" <Un**************@discussions.microsoft.com> wrote in
message news:98**********************************@microsof t.com...
Ok that worked. Now I have another problem.
I have database controls in my user control and I want to access them from my WebForm1.aspx. I found this on the net but I can't seem to figure out where to put the code. I"m not even sure if this will help me out with my problem

http://www.devx.com/vb2themax/Tip/18843

"Karl" wrote:

> How are you raising the event? You should be hooking into the

repeater's
> OnITemCommand event...not the linkbutton's click event..
>
> Karl
>
> "UnknownServices" <Un*************@discussions.microsoft.com> wrote in > message news:51**********************************@microsof t.com...
> > I've added a LinkButton to a repeater control and I set the link

button as
> > follows:
> >
> > <asp:LinkButton ID="DLLinkButton" CommandArgument='<%#
> > DataBinder.Eval(Container.DataItem, "DownloadID")%>' Runat=server
> > CommandName="DLCount" >Download Now!</asp:LinkButton>
> >
> > When I click this button it dosen't do anything instead of calling the > > function I created.
> >
> > BTW, is this the best way to go about calling the function? I tried > putting
> > in the onClick command the following:
> >
> > OnClick='<% DLCount(DataBinder.Eval(Container.DataItem,

"DownloadID"))%>'
> >
> > But that didn't work. Any Ideas?
>
>
>


Nov 18 '05 #5
I use it as a menu and for hte database controls. I did drag the Data
Controls to the designer from the toolbox. But can you tell me how to make a
class that I can reuse or possibly give me a link for a tutorial or
something. Anything would be of great help.

BTW: Whats the best way to add a use control to a page?

Through the code-behind or through the html?

"Karl" wrote:
How are you including this User Control on your main page? If you aren't,
then you shouldn't be using a UserControl, but instead should just be
creating a plain class. Did yo drag and drop your user control on your aspx
file? Does your User Control do anything visual or is it just business
logic (connect to DB, return dataset?). The explanation bellow assums you
are including the user control in your page for some type of visual
stuff...which is why you use a user control. Your follow up posts makes me
think maybe you just want a normal class (.vb).

Please let me know :)

Karl

"Unknown-Services" <Un*************@discussions.microsoft.com> wrote in
message news:CA**********************************@microsof t.com...
Hmm.. I really couldn't understand your post very well. May you please
reexplain it?

In my User Control (.ascx file) I have a DataSet, DataConnection etc. that
are all set to public and are created through VS.NET's designer. I'm

trying
to access them from a regular page (. aspx file) so I can run some code
using them.. Hope this explains more of what I need.

"Karl" wrote:
I'm not sure what you mean by database control, but if you want to access something that's in a user control from the main page, that isn't too hard.
Since you haven't given too much information, I see two possibilities: Your user control is either static or dynamic. In both cases its just a matter of setting the information you want public, or the methods you want to be able to call to public.

public class myControl
inherits UserControl

private _isLoaded as boolean = tru
public readonly property IsLoaded() as boolean
get
return _isLoaded
end get
end property
....
public sub DoSomething()
End Sub
...
end class
from webform1, you are loading the control like:
<mytag:myControl id="mine" runat="server" />

you can simply access mine.IsLoaded or mine.DoSomething

If you are dynamically loading the control, like:

Dim c as Control = Page.LoadControl("MyControl.ascx")
somePlaceholder.Controls.add(c)

you simply need to properly cast the control -->
Dim c as MyControl= ctype(Page.LoadControl("MyControl.ascx"), MyControl)
dim controlLoaded as boolean = c.IsLoaded
c.DoSomething
somePlaceholder.Controls.add(c)

Hope this Helps
Karl

"Unknown-Services" <Un**************@discussions.microsoft.com> wrote in
message news:98**********************************@microsof t.com...
> Ok that worked. Now I have another problem.
> I have database controls in my user control and I want to access them from > my WebForm1.aspx. I found this on the net but I can't seem to figure out > where to put the code. I"m not even sure if this will help me out with my > problem
>
> http://www.devx.com/vb2themax/Tip/18843
>
> "Karl" wrote:
>
> > How are you raising the event? You should be hooking into the
repeater's
> > OnITemCommand event...not the linkbutton's click event..
> >
> > Karl
> >
> > "UnknownServices" <Un*************@discussions.microsoft.com> wrote in > > message news:51**********************************@microsof t.com...
> > > I've added a LinkButton to a repeater control and I set the link
button as
> > > follows:
> > >
> > > <asp:LinkButton ID="DLLinkButton" CommandArgument='<%#
> > > DataBinder.Eval(Container.DataItem, "DownloadID")%>' Runat=server
> > > CommandName="DLCount" >Download Now!</asp:LinkButton>
> > >
> > > When I click this button it dosen't do anything instead of calling the > > > function I created.
> > >
> > > BTW, is this the best way to go about calling the function? I tried > > putting
> > > in the onClick command the following:
> > >
> > > OnClick='<% DLCount(DataBinder.Eval(Container.DataItem,
"DownloadID"))%>'
> > >
> > > But that didn't work. Any Ideas?
> >
> >
> >


Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2116
by: Mark | last post by:
I am looking for an example of using checkboxes in a repeater control where the checkbox state is persisted from page to page. Thank you, Mark
0
1776
by: Amir | last post by:
Hi every one This is the problem: I have a UserControl that contains a Repeater and a few LinkButton. The Repeater generate some linkButton. I use this control for implementing paging solution...
1
5400
by: olduncleamos | last post by:
Hello all, I am experimenting with the repeater control and ran into something that I wasn't expecting. I would appreciate if the experts can confirm or correct my understanding. Here is a...
3
4108
by: Shimon Sim | last post by:
I put linkbutton in a repeater header. I attached event handler in makeup as onclick="btnSort_Click". Made btnSort_Click method public. It doesn't fire if I click on it. I tried to attach it in...
1
6391
by: ratnakarp | last post by:
Hi, I have a search text box. The user enters the value in the text box and click on enter button. In code behind on button click i'm writing the code to get the values from the database and...
3
7786
by: renil | last post by:
I have a repeater control that displays info. from a datatable. Each row in the repeater has a checkbox. Also, I have a delete linkbutton outside the repeater control. What I'm trying to do when...
0
2781
by: Keith | last post by:
I have a repeater control that contains a HeaderTemplate and an ItemTemplate. Each item contains a checkbox with an ID of chkReconciled, and the header contains a single checkbox with an ID of...
0
2253
by: Keith | last post by:
I have a repeater control that contains a HeaderTemplate and an ItemTemplate. Each item contains a checkbox with an ID of chkReconciled, and the header contains a single checkbox with an ID of...
0
2536
by: Eugene Anthony | last post by:
The problem with my coding is that despite removing the records stored in the array list, the rptPages repeater control is still visible. The rptPages repeater control displayes the navigation...
5
13895
by: Peter Larsen [CPH] | last post by:
Hi, The following sample shows a LinkButton in the HeaderTemplate of a Repeater control. The problem is that i'm not able to access the linkbutton in code (in the cs file) as long as the...
0
7267
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6976
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5566
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4993
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1495
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
729
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
372
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.