Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
|
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 15th, 2009, 04:40 PM
Authorized User
 
Join Date: Mar 2009
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default ntier imar example and grid sorting

Hi! I've created a page with nTier imar xample ...

can you tell me how can I manage the order in this grid?


<asp:GridView ID="gvElenco" runat="server" AutoGenerateColumns="False" Width="99%" DataKeyNames="Id">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />

<Columns>
<asp:TemplateField ShowHeader="False" ItemStyle-Width="30">
<ItemTemplate>
<asp:Button ID="btnDettaglio" OnClick="btnDettaglio_Click" IDContratto='<%# Eval("ID") %>' runat="Server" CausesValidation="False" Text="Dettaglio" Width="60px" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="DescrizioneVenditore" HeaderText="Venditore" SortExpression="DescrizioneVenditore" meta:resourcekey="BoundFieldResource2" />
<asp:BoundField DataField="Codice" HeaderText="Cod" SortExpression="Codice" meta:resourcekey="BoundFieldResource2" />
<asp:BoundField DataField="Descrizione" HeaderText="Descrizione" SortExpression="Descrizione" meta:resourcekey="BoundFieldResource2" />

</Columns>
<RowStyle Height="25px" BackColor="#EEEEEE" ForeColor="Black" />
<AlternatingRowStyle BackColor="#DCDCDC" />
<FooterStyle BackColor="#003366" ForeColor="Black" Height="1px" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#003366" Font-Bold="True" Height="15px" ForeColor="White" />
</asp:GridView>

<asp:ObjectDataSource ID="odsContratti"
DataObjectTypeName="Spaanjaars.ContactManager.Busi nessEntities.Contratto"
runat="server"
DeleteMethod="Delete"
InsertMethod="Save"
SelectMethod="GetList"
TypeName="Spaanjaars.ContactManager.Bll.ContrattoM anager"
UpdateMethod="Save"
EnablePaging="False"
SelectCountMethod="SelectCountForGetList"
OnSelecting="odsContratti_Selecting">
<SelectParameters>
<asp:Parameter Name="ContrattoCriteria" Type="Object" />
</SelectParameters>
</asp:ObjectDataSource>
</div>

Thanks
 
Old May 15th, 2009, 04:53 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Please please please *read* the articles before you post follow up questions. Both article series (the 2.0 version and the 3.5 version) have an entire article dedicated to sorting.

Pffffff


Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old May 18th, 2009, 05:17 PM
Authorized User
 
Join Date: Mar 2009
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've read the article ... but I don't know where is error in my page!!

Can send me a suggestion?

Thanks
 
Old May 19th, 2009, 06:30 AM
Authorized User
 
Join Date: Mar 2009
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've found my problem!!

I've a grid view with filtering and sorting


only with sort or filter works OK

but with 2 options can't find right GetList method


is it possible to manage sort and filter?

Thanks
 
Old May 20th, 2009, 06:14 PM
Authorized User
 
Join Date: Mar 2009
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

There isn't a solution?? :-(((
 
Old May 21st, 2009, 09:33 AM
softomania
Guest
 
Posts: n/a
Default

The discussion is very helpful to me.

Software testing tutorial
 
Old May 24th, 2009, 09:24 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
There isn't a solution?? :-(((
I'm sure there is one. However, as I have indicated a couple of time before, you're not supplying enough information to get relevant answers. Without relevant context, background, a crystal clear problem description, a description of the required functionality and some of the code you have already written, I don't think anybody here will be able to help you out.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old May 24th, 2009, 09:53 AM
Authorized User
 
Join Date: Mar 2009
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your reply imar! I'm trying to apply to your example a solution for sort grid.

My GridView has a search form and I would like to allow sort gridview


PHP Code:


   
<asp:GridView ID="gvElenco" runat="server" AutoGenerateColumns="False"
        
Width="99%" ForeColor="#333333" Font-Names="Verdana" DataKeyNames="Id"
        
BorderColor="#999999" BorderStyle="None" BorderWidth="1px" ShowFooter="true" AllowSorting="True" CellPadding="8" GridLines="Vertical">
        <
FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <
RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
        <
EditRowStyle BackColor="#999999" />
        <
PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <
HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
        <
AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        <
Columns>
            <
asp:TemplateField ShowHeader="False" ItemStyle-Width="30">
                <
ItemTemplate>
                    <
asp:Button ID="btnDettaglio" OnClick="btnDettaglio_Click" IDAttivita='<%# Eval("ID") %>' runat="Server" CausesValidation="False" Text="Dettaglio" Width="60px" />                     
                 </
ItemTemplate>
            <
ItemStyle Width="30px"></ItemStyle>
            </
asp:TemplateField
            <
asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" ItemStyle-HorizontalAlign="Left" Visible="false" meta:resourcekey="BoundFieldResource2" />
            <
asp:BoundField DataField="DescrizioneAttivita" HeaderText="Attivita" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left" SortExpression="DescrizioneAttivita" meta:resourcekey="BoundFieldResource2" />
        </
Columns>
        <
RowStyle Height="25px" BackColor="#EEEEEE" ForeColor="Black"  />
        <
AlternatingRowStyle BackColor="#DCDCDC"  />
        <
FooterStyle BackColor="#003366" ForeColor="Black" Height="1px" />
        <
PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
        <
SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
        <
HeaderStyle BackColor="#003366" Font-Bold="True" Height="15px" ForeColor="White" />
    </
asp:GridView>
    
    
        <
asp:ObjectDataSource ID="odsAttivita"               
        
DataObjectTypeName="Spaanjaars.ContactManager.BusinessEntities.Attivita" 
        
runat="server" 
        
DeleteMethod="Delete" 
        
InsertMethod="Save" 
        
SelectMethod="GetList" 
        
TypeName="Spaanjaars.ContactManager.Bll.AttivitaManager" 
        
UpdateMethod="Save" 
        
EnablePaging="False" 
        
SelectCountMethod="SelectCountForGetList"
        
OnSelecting="odsAttivita_Selecting">
        <
SelectParameters>
            <
asp:Parameter Name="AttivitaCriteria" Type="Object" />
        </
SelectParameters>
    </
asp:ObjectDataSource>




Search method....

protected 
void odsAttivita_Selecting(object senderObjectDataSourceSelectingEventArgs e)
    {        
        
AttivitaCriteria attivitaCriteria = new AttivitaCriteria();

        if(
tbRicercaDescrizioneAttivita.Text == "")
            
attivitaCriteria.DescrizioneAttivita null;
        else
            
attivitaCriteria.DescrizioneAttivita tbRicercaDescrizioneAttivita.Text;

        
e.InputParameters["AttivitaCriteria"] = attivitaCriteria;
    } 
 
Old May 24th, 2009, 10:24 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

For now, all I can suggest is based on what you've posted: create a method that accepts a search criterium and a sortExpression and combine the logic from the previous methods.

You're making this very hard for us. As I said before, it would be help if you'd describe the problem in detail. Explain what you're trying to accomplish, explain your requirements, tells us what you've done so far,show us the code you tried out and the errors you're running into. We're not going to program the solution for you; all I can do is help you find your own way in it.

Right now, all you say is "I have search form" and dump some code on us (with a PHP header?????).

If you can't ask better questions, I can't help you out here anymore....


Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old May 29th, 2009, 04:10 PM
Authorized User
 
Join Date: Mar 2009
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar!! Thanks for your help

I've tried to create new GetList method for manage sorting and search criteria...

error that I see tell me that 'ods_PDR' doesn't support soerting IEnumerable. Autocatic sorting supported only by DataView, DataTable e DataSet.


HTML Code:

<asp:ObjectDataSource ID="ods_PDR"               
      DataObjectTypeName="Spaanjaars.ContactManager.BusinessEntities.PDR" 
        runat="server" 
        DeleteMethod="Delete" 
        InsertMethod="Save" 
        SelectMethod="GetList" 
        TypeName="Spaanjaars.ContactManager.Bll.PDRManager" 
        UpdateMethod="Save" 
        EnablePaging="False" 
        SelectCountMethod="SelectCountForGetList"
        OnSelecting="odsPDR_Selecting">
        <SelectParameters>
            <asp:Parameter Name="PDRCriteria" Type="Object" />
        </SelectParameters>
    </asp:ObjectDataSource>


I've already post gridview HTML in my last post
Code:
        public static PDRCollection GetList(PDRCriteria PDRCriteria, string sortExpression, int startRowIndex, int maximumRows)
        {
            PDRCollection myCollection = PDRDB.GetList(PDRCriteria);

            if (!string.IsNullOrEmpty(sortExpression))
            {
                myCollection.Sort(new PDRComparer(sortExpression));
            }
            if (startRowIndex >= 0 && maximumRows > 0)
            {
                return new PDRCollection(myCollection.Skip(startRowIndex).Take(maximumRows).ToList());
            }
            return myCollection;
        }



and the criteria manager....

   protected void odsPDR_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
    {        
        PDRCriteria pdrCriteria = new PDRCriteria();

        if(ddlRicercaCodicePDR.SelectedValue == "Tutti...")
            pdrCriteria.CodicePDR = null;
        else
            pdrCriteria.CodicePDR = ddlRicercaCodicePDR.SelectedValue;


        if(ddlRicercaDescrizionePDR.SelectedValue == "Tutti...")
            pdrCriteria.DescrizionePDR = null;
        else
            pdrCriteria.DescrizionePDR = ddlRicercaDescrizionePDR.SelectedValue;


        if(ddlRicercaProvincia.SelectedValue == "Tutti...")
            pdrCriteria.CodiceProvincia = null;
        else
            pdrCriteria.CodiceProvincia = ddlRicercaProvincia.SelectedValue;


        if(ddlRicercaRegione.SelectedValue == "Tutti...")
            pdrCriteria.CodiceRegione = null;
        else
            pdrCriteria.CodiceRegione = ddlRicercaRegione.SelectedValue;


        if(ddlRicercaAreaPrelievo.SelectedValue == "Tutti...")
            pdrCriteria.CodiceAreaPrelievo = null;
        else
            pdrCriteria.CodiceAreaPrelievo = ddlRicercaAreaPrelievo.SelectedValue;


        e.InputParameters["PDRCriteria"] = pdrCriteria;
    }





Similar Threads
Thread Thread Starter Forum Replies Last Post
about grid view sorting rdinesh1975 ASP.NET 2.0 Professional 3 August 9th, 2007 05:27 AM
client side sorting and paging in data grid prankur ASP.NET 1.0 and 1.1 Basics 1 February 3rd, 2006 12:05 PM
client side sorting and paging in data grid prankur ASP.NET 1.0 and 1.1 Professional 1 February 3rd, 2006 12:00 PM
Data grid sorting on page 707 matejx BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 6 December 2nd, 2005 05:43 AM
Sorting in Data Grid matt.fields ASP.NET 1.0 and 1.1 Basics 0 October 21st, 2003 12:39 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.