473,385 Members | 1,320 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.

repeater control with selection

Hi,
I wish to create a repeater control in c#.net that allows for the
selection of rows, any idea how this can be done.

Regards

Robert
Jun 27 '08 #1
5 4093
On May 30, 10:23*am, Robert Smith
<RobertSm...@discussions.microsoft.comwrote:
Hi,
* * *I wish to create a repeater control in c#.net that allows for the
selection of rows, any idea how this can be done.

Regards

Robert
why you want to use a repeater and not a grid for example?

what you mean with selection, you can use a checkbox column and when
checked you change the Css of the row, this is an indication of
"selection"
Jun 27 '08 #2
Hi Ignacio,
I wish to use a repeater because it is lighter than a gridview
and my supervisor recommended it.
"Ignacio Machin ( .NET/ C# MVP )" wrote:
On May 30, 10:23 am, Robert Smith
<RobertSm...@discussions.microsoft.comwrote:
Hi,
I wish to create a repeater control in c#.net that allows for the
selection of rows, any idea how this can be done.

Regards

Robert

why you want to use a repeater and not a grid for example?

what you mean with selection, you can use a checkbox column and when
checked you change the Css of the row, this is an indication of
"selection"
Jun 27 '08 #3
A Gridview isn't always "lighter" or heavier that a Repeater; it depends
what you have in the control, how many rows and columns, and how many child
controls. Besides Gridview already has all the stuff you need, and since
your supervisor is asking you to reinvent the wheel by using a Repeater,
there's a pretty good chance he / /she is a real moron.
Peter

"Robert Smith" <Ro*********@discussions.microsoft.comwrote in message
news:7C**********************************@microsof t.com...
Hi Ignacio,
I wish to use a repeater because it is lighter than a gridview
and my supervisor recommended it.
"Ignacio Machin ( .NET/ C# MVP )" wrote:
>On May 30, 10:23 am, Robert Smith
<RobertSm...@discussions.microsoft.comwrote:
Hi,
I wish to create a repeater control in c#.net that allows for the
selection of rows, any idea how this can be done.

Regards

Robert

why you want to use a repeater and not a grid for example?

what you mean with selection, you can use a checkbox column and when
checked you change the Css of the row, this is an indication of
"selection"
Jun 27 '08 #4
Hi,

I have a repeater control which is selectable, meaning that the selected row changes style on selection.
<asp:Repeater ID="repeaterList" runat="server" OnItemCommand="repeaterList_ItemCommand" OnItemDataBound="repeaterList_ItemDataBound">
<HeaderTemplate>
<table title="tableList" id="tableList" width="600px" style="font-size:small; font-family:Arial; border-style:solid; border-width:1px">
<tr style="background-color:#5D7B9D;color:White">
<th>Bill ID</th>
<th>Customer Name</th>
<th>Bill Number</th>
<th>Bill Date</th>
<th>Bill Total</th>
</tr>
</HeaderTemplate>

<ItemTemplate>
<tr title="trListRow" id="trListRow" class="tmpClass"
style="background-color:#F7F6F3; color:#333333"
onmouseover="javascript:setMouseOverColor(this);"
onmouseout="javascript:setMouseOutColor(this);"
onclick="javascript:setMouseClicked(this, <%# Container.ItemIndex %>);">
<td id="tdBillID"><%#DataBinder.Eval(Container.DataIte m, "BillID")%></td>
<td><%#DataBinder.Eval(Container.DataItem, "CustomerName")%></td>
<td><%#DataBinder.Eval(Container.DataItem, "BillNumber")%></td>
<td><%#DataBinder.Eval(Container.DataItem, "BillDate")%></td>
<td><%#DataBinder.Eval(Container.DataItem, "BillTotal") %></td>
<%--<td><asp:Button ID="click" Runat="server" CommandName="click" CommandArgument=<%# Container.ItemIndex %>></asp:Button></td>--%>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr id="trListRow" style="background-color:#FFFFFF; color:#284775"
onmouseover="javascript:setMouseOverColor(this);"
onmouseout="javascript:setMouseOutColor(this);"
onclick="javascript:setMouseClicked(this, <%# Container.ItemIndex %>);">
<td id="tdBillID"><%#DataBinder.Eval(Container.DataIte m, "BillID")%></td>
<td><%#DataBinder.Eval(Container.DataItem, "CustomerName")%></td>
<td><%#DataBinder.Eval(Container.DataItem, "BillNumber")%></td>
<td><%#DataBinder.Eval(Container.DataItem, "BillDate")%></td>
<td><%#DataBinder.Eval(Container.DataItem, "BillTotal") %></td>
</tr>

</AlternatingItemTemplate>

<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
and the Javascript functions changing style:
function setMouseOverColor(element)
{
oldgridSelectedColor = element.style.backgroundColor;
element.style.backgroundColor='#DEECEF';
element.style.cursor='hand';
}

function setMouseOutColor(element)
{
element.style.backgroundColor = oldgridSelectedColor;
element.style.textDecoration = 'none';
}

function setMouseClicked(element, index)
{
ResetTheTable(index);
oldgridSelectedColor = "#DEECEF";
}

function ResetTheTable(index)
{
var vTable = document.getElementById("tableList");
var vRows = vTable.getElementsByTagName("tr");

// we start from 1 because 0 is the header
for(i = 1; i < vRows.length; i++){
if(i%2)
{
vRows[i].style.backgroundColor = '#F7F6F3';
vRows[i].style.color = '#333333';
vRows[i].style.fontWeight = 'normal';
}
else
{
vRows[i].style.backgroundColor = '#FFFFFF';
vRows[i].style.color = '#284775';
vRows[i].style.fontWeight = 'normal';
}
}
vRows[index+1].style.backgroundColor = '#DEECEF';
vRows[index+1].style.color = '#333333';
vRows[index+1].style.fontWeight = 'bold';
}

This works very nicely, changing the style of the row when a row is selected.

What I would like help with is I don't know how to store th index of the selected row so I can later access it from my C# code. I am pretty new to ASP development, I tried storing the selection in <inputand <asp:Labelvariables but the values don't seem to be visible from the C# side.
Any help would be appreciated.

Thanks,
Blanka
Jun 27 '08 #5
Sorry, the declaration of the asp:Repeater got a bit trimmed on the last post. Basically in each TR I assign javascript functions for the onmouseover, onmouseout, onclick events (the stuff that didn't get trimmed). The reason there are 2 blocks of event assignments is that I use and ItemTemplate and an AlternatingItemTemplate in the repeater.

Sorry if I'm not very clear.

Thanks,
Blanka
Jun 27 '08 #6

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

Similar topics

1
by: ShijuFrancis | last post by:
Hi All, I have got a tricky situation out here... I have got a repeater control in which one column is dropdown list control. Say for instacnce I have got the values A,B,C,D in the drop down and...
5
by: Scott Lyon | last post by:
I am having a strange problem. The program is a bit complex, but I'll try to simplify what I can. I apologize if this is complicated, but I think this would still be simpler than posting a bunch of...
0
by: Jeff | last post by:
After I bind the repeater control in the form_load event, it builds multiple lines based on the number of rows in the dataset. In the repeater control, I have a textbox and a dropdown list box. ...
4
by: MattB | last post by:
This is just a rephrased version of a question I posted earlier. I think I'm closer now, so it seemed worthy of a new (more specific) post. In my repeater I'm dynamically creating text boxes, so...
1
by: Ravi | last post by:
Hi, I have a radio button list and a dropdownlist inside a repeater control. Want to hide or display the dropdownlist based on selection in radiobuttonlist. I can add the...
6
by: Christoph Boget | last post by:
Could someone point me to a resource that discusses how to set up other controls (input box, checkbox, drop down list), etc to be used in a Repeater? I'm not having a problem displaying text in...
1
by: dinesh | last post by:
After a selection a selection is made, the form posts to the server, but no data gets displayed in the repeater. no errors are given. <form id="Form1" runat="server"> Category:...
1
by: Christiaan Nieuwlaat | last post by:
Hi everyone, Could you please help me with this? I need to create a table in which resultdata from a sql server table can be shown and/or edited by using controls, for instance the radiobutton....
2
by: RichardH | last post by:
Hi, I have x number of table rows that all should have a checkbox and a dropdownlist on each row. The checkbox could be checked and the dropdown should contain y number of values that are...
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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.