"tshad" <> wrote in message
news:O%...
> "Kevin Spencer" <> wrote in message
> news:%23jV7$...
>>> How would I use that to determine the type of control if I were passed
>>> something like:
>>>
>>> sub something(s as object, e as DataListCommandEventArgs)
>>
>> Huh??? Did someone pass a sub to you? Just pass it back.
>
> Actually, I might have this wrong. I am using an EventArgs not the
> DataListCommandEventArgs (I think).
>
> I have a Repeater object which has a bunch of asp:Labels and asp:Link
> buttons. This Repeater object is part of a DataList object. I need to
> get to the parent of the Repeater this control is part of.
>
> A LinkButton might look like:
>
> <asp:LinkButton id="Interviews" runat="server" Text='<%#
> DataBinder.Eval(Container, "DataItem.Interviews") %>'
> onClick="Interviews_Click" />
>
> I then have a routine:
> ************************************************** ***********
> sub Interviews_Click(src as object, args as EventArgs)
>
> end sub
> ************************************************** **************
>
> I need to get the DataList object that is the parent of the "Interviews"
> control. The Interviews control has the detail information I need to get
> and my repeater is a summary. I hope I am explaining this right.
>
> Once I get the Datalist control, I can use FindControl to get the object I
> am really after (a reference code, for instance).
>
> So I have something like
>
> <asp
ataList \> objects..
> <asp:repeater \> objects such as the link button below
> <asp:LinkButton \>
>
> I hope that isn't too confusing (it is to me).
Tom, I think I see what you're getting at, and you may be going about it the
wrong way.
First of all, when a LinkButton is clicked inside of a Repeater, DataList or
DataGrid, an ItemCommand event is raised in the Repeater, DataList or
DataGrid. The RepeaterCommandEventArgs passed to that event handler will
supply it with the CommandName and CommandArgument properties which came
from the LinkButton, and in fact, the CommandSource property will return a
reference to the LinkButton itself. You will also get the Item property,
which is a reference to the RepeaterItem this LinkButton is inside of.
Of course, the sender parameter will be a reference to the Repeater object.
If that is inside of the DataList (or, more accurately, inside of a
DataListItem), then you can get to the DataList by:
private void MyRepeater_ItemCommand(object sender, RepeaterCommandEventArgs
e)
{
Repeater rpt = (Repeater) sender;
Control rptParent = rpt.Parent;
DataList dataList = (DataList) rptParent.Parent; // I think
}
But this only solves half of your problem. The question is exactly what do
you plan to get from that DataList? It sounds like you plan to access the
data to which the list was bound, but it won't be there on a PostBack.
Is this a generic scenario, or something that just happens on a single page?
John Saunders