Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

i've display a dataTable in a repeater, how can filter the display?

Posted on 2007-11-14
8
Medium Priority
?
244 Views
Last Modified: 2008-02-01
i 'd like to be able to filter depending the header that was pressed on
a table displayed after a repeater?
the repeater repeats the  table rows.

i think there must be a solution somewhere, i need the link.
0
Comment
Question by:toshi_
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 10

Expert Comment

by:Oliver Amaya
ID: 20280746
Hi, I'm not sure exactly how you're doing the handling of the datatable and repeater, in any case you should be able to cause a postback when a header is clicked, and to filter the datatable use the RowFilter property of the DefaultView:

myDataTable.DefaultView.RowFilter = "lastname = 'smith'";

http://msdn2.microsoft.com/en-us/library/system.data.dataview.rowfilter(vs.71).aspx
0
 

Author Comment

by:toshi_
ID: 20284446
hi joex911,

do you like porshe cars?
here 's the way i'm handling the datatable and repeater.


html
----------------------------------------------------------------------------------------------------------------
<TABLE>
  <TR>
      <TD class="td_ca_ecolog_6">level min</TD>
      <TD class="td_ca_ecolog_7">volume</TD>
  </TR>
</TABLE>

<asp:Panel id="panelEcologsZoneWrapper" class="cu_ecologZoneWrapper" runat="server">
      <table id="sub_account_zone" border="1px" >
            <asp:Repeater ID="repEcolog" Runat="server" OnItemDataBound="treatItem" >
                  <ItemTemplate>
                        <tr style="over:red;color:grey;" onmouseover="this.className='over'" onmouseout="this.className=''">
                                     <td class="td_ca_ecolog_5">&nbsp;<%# DataBinder.Eval(Container.DataItem, "depth_min") %></td>
                              <td class="td_ca_ecolog_6">&nbsp;<%# DataBinder.Eval(Container.DataItem, "volume") %></td>
                              </tr>
                        </ItemTemplate>
                  </asp:Repeater>
            </table>      
</asp:Panel>
----------------------------------------------------------------------------------------------------------------
code behind:
....
      repEcolog.DataSource = controller_.FetchEcologList();      
      repEcolog.DataBind();
....
i have a table for headers because i want them fix, when i scroll the values.
my controller return the dataTable right to the repeater, but i could get it to a local dataTable of the page
(would it make it faster instead of recreating a method in controller?)
what i need to know is where to launch the filter, with javascript on the header
something out of the repeater ?

i need to reorder increasing or decreasing, i want my header links as toogle buttons, once click filter increasing,
once clicked again filter decreasing.


note: you can see that i have a treatItem method, it's empty it's doing anything.

0
 
LVL 10

Expert Comment

by:Oliver Amaya
ID: 20288406
Ok, so what you want to do is sort the table in ascending or descending order, not filter the results? I think that for this it be easier if you use a DataGrid control (.NET 1.1) or a GridView control (.NET 2.0), they provide the means to add the sorting functionality to your data.

http://dotnetjunkies.com/Article/B7C5AB3C-4D2E-4800-A071-6F40D57699C3.dcik
http://aspnet.4guysfromrolla.com/articles/052202-1.aspx
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:toshi_
ID: 20288851
i'm gonna try with dataGrid as i'm using .NET 1.1

hem! anywas, is there a possibility to do ti via my poor repeater?
0
 
LVL 10

Expert Comment

by:Oliver Amaya
ID: 20289327
You could do it with the repeater, maybe use a asp:hyperlink for the headers off each column, then on the click event apply a sort to your datatable, also you need to keep track in a session variable if it should be ascending (ASC) or descending (DESC):


if(session["SortDir"].ToString() == "ASC")
  DataTable.Sort = "Column DESC";
else
  DataTable.Sort = "Column ASC";

Open in new window

0
 

Author Comment

by:toshi_
ID: 20302818
shure, i found that
dtTemp.DefaultView.Sort = "weight DESC";
would sort my table on my weight column,

but how to fire the event to be able to sort this in code behind?
i can not add event to the hyperlink, only javascript.
0
 
LVL 10

Accepted Solution

by:
Oliver Amaya earned 1500 total points
ID: 20304134
If you use an asp:linkbutton you should be able to use its onclick event on your code-behind.
<asp:linkbutton id="LinkButton1" runat="server">Link Test</asp:linkbutton>
 
private void LinkButton1_Click(object sender, System.EventArgs e)
{
  // code to sort your table
}

Open in new window

0
 

Author Comment

by:toshi_
ID: 20326933
thanks a lot ,
i succeed with your help.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question