Repeater LinkButton

G

Guest

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?
 
K

Karl

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

Karl
 
K

Karl

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
 
G

Guest

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.
 
K

Karl

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
 
G

Guest

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?
 

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

Top