Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old May 15th, 2009, 05: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
  #2 (permalink)  
Old May 15th, 2009, 05:53 PM
Imar's Avatar
Wrox Author
Points: 71,164, Level: 100
Points: 71,164, Level: 100 Points: 71,164, Level: 100 Points: 71,164, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,960
Thanks: 79
Thanked 1,559 Times in 1,536 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!
  #3 (permalink)  
Old May 18th, 2009, 06: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
  #4 (permalink)  
Old May 19th, 2009, 07: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
  #5 (permalink)  
Old May 20th, 2009, 07:14 PM
Authorized User
 
Join Date: Mar 2009
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

The discussion is very helpful to me.

Software testing tutorial
  #7 (permalink)  
Old May 24th, 2009, 10:24 AM
Imar's Avatar
Wrox Author
Points: 71,164, Level: 100
Points: 71,164, Level: 100 Points: 71,164, Level: 100 Points: 71,164, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,960
Thanks: 79
Thanked 1,559 Times in 1,536 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!
  #8 (permalink)  
Old May 24th, 2009, 10: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;
    } 
  #9 (permalink)  
Old May 24th, 2009, 11:24 AM
Imar's Avatar
Wrox Author
Points: 71,164, Level: 100
Points: 71,164, Level: 100 Points: 71,164, Level: 100 Points: 71,164, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,960
Thanks: 79
Thanked 1,559 Times in 1,536 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!
  #10 (permalink)  
Old May 29th, 2009, 05: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;
    }
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
about grid view sorting rdinesh1975 ASP.NET 2.0 Professional 3 August 9th, 2007 06: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 01:39 PM



All times are GMT -4. The time now is 03:46 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.