473,385 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Accessign System.Web.UI.WebControls.Repeater in code

I have a Repeater control in an app I'm updating. I need to write
code (event method) when a user clicks on one of the columns in the
control. But there is no method like "Repeater_OnClick" or something
like that. Is there a way to get access to this control with an event
method of some kind?

If not, (and here's where my inexperience in web development will show
through), is there another server side grid type control that I could
switch to? I would prefer not to do this as there is a lot of other
code (in javascript, etc) that is tied to this control but if I have
no choice I'm not sure which is the best to use.

Jun 15 '07 #1
6 3742
On Jun 16, 12:21 am, Doogie <dnlwh...@dtgnet.comwrote:
I have a Repeater control in an app I'm updating. I need to write
code (event method) when a user clicks on one of the columns in the
control. But there is no method like "Repeater_OnClick" or something
like that. Is there a way to get access to this control with an event
method of some kind?

If not, (and here's where my inexperience in web development will show
through), is there another server side grid type control that I could
switch to? I would prefer not to do this as there is a lot of other
code (in javascript, etc) that is tied to this control but if I have
no choice I'm not sure which is the best to use.
hi...

I am not sure of exactly what problem you are referring ...
But if the problem is catching repeater's click event in server
side...
then try itemCommand event of reapeater... and use e.commandname
e.commandsource etc... to solve your problem

Thanks
Masudur


Jun 16 '07 #2
Hi Masudur,

I put some code in the itemCommand event for my repeater, put a
breakpoint on that code, clicked on the grid when I ran the app and
nothing happened. What action causes the itemCommand event to be
executed?

Jun 18 '07 #3
On Jun 18, 6:30 pm, Doogie <dnlwh...@dtgnet.comwrote:
Hi Masudur,

I put some code in the itemCommand event for my repeater, put a
breakpoint on that code, clicked on the grid when I ran the app and
nothing happened. What action causes the itemCommand event to be
executed?
I am not sure what is going on there...
here how it should go...

<asp:Repeater ID="Repeater1" runat="server"
DataSourceID="SqlDataSource1" OnItemCommand="Repeater1_ItemCommand1">

you put some kind of button or link button .... in itemTemplate or
AlternetingItemTemplete
for example

<ItemTemplate>
<div style="background-color:#cccccc">
<asp:Button ID="btnSelect" Text="Select"
runat="server" CommandName="Select" />
<asp:Label ID="lblName" runat="server" Text=<%#
DataBinder.Eval(Container.DataItem, "Name") %>></asp:Label>
</div>
</ItemTemplate>

as you can see in commandName property of the button i put "Select" As
the command name after that in codebehind file

protected void Repeater1_ItemCommand1(object source,
RepeaterCommandEventArgs e)
{
if (e.CommandName == "Select")
{
//do some code...
}
}

i think i didn't understand what the actual problem is ...
can you be a little bit more descriptive.

Thanks
Masudur
http://munnacs.110mb.com

Jun 19 '07 #4
Well, the problem has kind of changed.

Here's an example of what my repeater looks like in html (this is a
partial example for space sake):

<asp:repeater ID="RptTrip" Runat="server" EnableViewState="false">
<ItemTemplate>
<trip_detail_info trip_detail_id ='<%#
Container.DataItem("trip_detail_id")%>'
leg_start_dt = '<%#
Container.DataItem("leg_start_dt")%>' />
</ItemTemplate>
</asp:repeater>

This grid is tied to an xsl document. I would like to set this up so
that I can write a method in VB.NET to access the data in this
control. At this point, I don't need a Repeater control event
anymore, I have a button that I've created - outside of the control -
that will have code behind it to do the work I need.

But I need to know what the data is inside the control. The Repeater
control appears to have no properties/methods, etc of any kind that
will show me what data is inside of it as far as I can tell. So I
can't figure out how to "read my data".

I am thinking that somehow I need to read the xsl but am not sure
there either. At this point, I am not sure what the best approach is
to accomplish this.

Jun 19 '07 #5
On Jun 19, 9:20 pm, Doogie <dnlwh...@dtgnet.comwrote:
Well, the problem has kind of changed.

Here's an example of what my repeater looks like in html (this is a
partial example for space sake):

<asp:repeater ID="RptTrip" Runat="server" EnableViewState="false">
<ItemTemplate>
<trip_detail_info trip_detail_id ='<%#
Container.DataItem("trip_detail_id")%>'
leg_start_dt = '<%#
Container.DataItem("leg_start_dt")%>' />
</ItemTemplate>
</asp:repeater>

This grid is tied to an xsl document. I would like to set this up so
that I can write a method in VB.NET to access the data in this
control. At this point, I don't need a Repeater control event
anymore, I have a button that I've created - outside of the control -
that will have code behind it to do the work I need.

But I need to know what the data is inside the control. The Repeater
control appears to have no properties/methods, etc of any kind that
will show me what data is inside of it as far as I can tell. So I
can't figure out how to "read my data".

I am thinking that somehow I need to read the xsl but am not sure
there either. At this point, I am not sure what the best approach is
to accomplish this.
hi...
First can you please make sure that your View state persists... by
enableViewState = true...

foreach(RepeaterItem item in Repeater1.Items)
{
if (item.ItemType == ListItemType.AlternatingItem ||
item.ItemType == ListItemType.Item)
{
Label lbl = (Label)item.FindControl("lblName");
if (lbl != null)
{
string Name = lbl.Text.Trim();
}
}
}

Thanks

Masudur
www.kaz.com.bd
http://munnacs.110mb.com

Jun 20 '07 #6
Hi Masudur,
I found a way around my issue. It wasn't exactly what I planned on
doing, I stored the data I needed to access from the repeater grid
inside a hidden control and used that to do what I need. Since I
won't ever be using much data at any given time, this seems to work
well (and gets me around a problem that has been taking days to figure
out!)
Jun 20 '07 #7

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

Similar topics

0
by: Eric Diana | last post by:
I am trying to place an strings into an array of strings I am declaring as Dim Fields() As String I have another variable im doing the same thing with and it works. Public Shared Operations()...
2
by: Shannon | last post by:
I am having a very strange issue with my asp.net application. I have created a datagrid which dynamically gets populated from a person choosing a value from a dropdown list and entering a quantity...
0
by: muralidharan | last post by:
WebForm1.aspx Code: <%@ Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI" Assembly="ComponentArt.Web.UI" %> <ComponentArt:TreeView id="TreeView1" Height="520"...
1
by: Zenobia | last post by:
How do I bind an array, arrayList or even a stack to a repeater containing hyperlinks. The data structure (array, arrayList or even a stack) has dates in ISO format "YYYY-MM-DD". The repeated...
3
by: Luis Esteban Valencia | last post by:
A page let of work for me I commented almost all lines but nothing the code is this
3
by: Patrick.O.Ige | last post by:
I'm loading an Array below but getting the error "Object reference not set to an instance saying 'ItemNumber = CType(Args.Item.FindControl("ItemNumber"), TextBox).Text' is the error line. I DON'T...
2
by: Robert | last post by:
Hi, if I create a class A with some properies, then create classes B and C derived from A, later create and ArrayList filled with some B and C items. This list I would like to use as a datasource...
1
by: thithi | last post by:
Please help me " System.Data.SqlClient.SqlException: Prepared statement '(@Name varchar(100),@Describes varchar(100),@Money char(10))Upda' expects parameter @Describes, which was not supplied. at...
1
by: differentsri | last post by:
THIS IS AN ASP.NET 1.1 APPLICATION IAM TRYING TO UPDATE THE FIELD BUT I AM NOT ABLE TO UPDATE IT? CAN U TELL THE REASON ? IT IS GIVING THE FOLLOWING ERROR BELOW I HAVE ALSO GIVEN THE CODE OF...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.