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
  #11 (permalink)  
Old May 29th, 2009, 06:55 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

This is going to take a very long time...... You seem to be missing a few fundamental and important concepts about .NET. Can you tell me what you already know about .NET in general and ASP.NET in particular? Maybe this whole N-Layer thing is a bit too much for you at this stage? Understanding what you know would make it easier for me to understand what to explain and what not.

I don't see how you set up sorting anywhere. You haven't desinated any parameter for it (or for the paging parameters) so I am not sure why you think it would work like this. Have you tried running the ODS configuration wizard to look for your method?

Also, this whole Spaanjaars* thing is called like that because it was in my application. In your case, you probably don't want to use my namespace but come up with your own instead. I don't call stuff Microsoft.Something either.... ;-)

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!
  #12 (permalink)  
Old June 4th, 2009, 07:50 AM
Authorized User
 
Join Date: Mar 2009
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

--
Also, this whole Spaanjaars* thing is called like that because it was in my application. In your case, you probably don't want to use my namespace but come up with your own instead. I don't call stuff Microsoft.Something either.... ;-)
--
Yesssssssssssssss yeeeeeeeessss yeeeeeeeessssssss I know this!!!
As I've written in my last posts I'm making test for learn how to use the best n-tier solution ... I'm not creating a specific web application! I'm only creating test pages.


--
Have you tried running the ODS configuration wizard to look for your method
--
Do you thinks that is it possible to integrate your "search criteria" solution with ODS sorting method?? (without creating a specific sorting method in manager layer)


Thanks!!
  #13 (permalink)  
Old June 5th, 2009, 03:42 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:
Do you thinks that is it possible to integrate your "search criteria" solution with ODS sorting method?? (without creating a specific sorting method in manager layer)
No. If you want to offer searching *and* sorting, you need to create a method that accepts searching *and* sorting criteria.

That's not so bad, is it?

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!
  #14 (permalink)  
Old June 5th, 2009, 12:44 PM
Authorized User
 
Join Date: Mar 2009
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your reply!!!

Can you tell me what I have to change modify in the method that I've posted in my last post??


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).Tak e(maximumRows).ToList());
}
return myCollection;
}


Thanks
  #15 (permalink)  
Old June 7th, 2009, 07:09 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

There's no code in your last post so I am not sure what method you are referring to.

The method you just posted looks fine; it does indeed support filtering, sorting and paging. For the GridView to work with this method, you need to set up the attributes like AllowSorting and AllowPaging. For the ODS you need to set up attributes like SortParameterName, EnablePaging and SelectCountMethod as I have shown in my articles. Also, in order for paging to work, you need to create a SelectCountMethod method that counts the number of records based on the same search criteria. My article on Sorting shows you how to accomplish this in detail.

Does this help?

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!
  #16 (permalink)  
Old June 7th, 2009, 02:43 PM
Authorized User
 
Join Date: Mar 2009
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for help me... I hope to resolve this problem :-((( ... are many days that I try to find a solution


It isn't necessary to manage pagination for me ... I would like to find a solution only for manage sorting and filtering ... I pagination doesn't works no problem :-)



Quote:
For the GridView to work with this method, you need to set up the attributes like AllowSorting and AllowPaging.
This was already OK, as you can see in my old posts

Quote:
For the ODS you need to set up attributes like SortParameterName, EnablePaging and SelectCountMethod as I have shown in my articles.
I've added SelectCountMethod in ODS but I don't know the name of the method to call

This is new GetList method that I've created for manage search criteria and sorting...

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).Tak  e(maximumRows).ToList());
            }
            return myCollection;
        }

and this is my HTML code:

HTML Code:
<asp:GridView ID="gvElenco" runat="server" AutoGenerateColumns="False" OnSorting="GridView1_Sorting"
        Width="99%" ForeColor="#333333" Font-Names="Verdana" DataKeyNames="CodicePDR"
        BorderColor="#999999" BorderStyle="None" BorderWidth="1px" ShowFooter="true" AllowSorting="True" CellPadding="8" GridLines="Vertical">
        <Columns>
            <asp:BoundField DataField="CodicePDR" HeaderText="Codice" SortExpression="CodicePDR" ItemStyle-HorizontalAlign="Left" meta:resourcekey="BoundFieldResource2" />
            <asp:BoundField DataField="DescrizionePDR" HeaderText="Descrizione" SortExpression="DescrizionePDR" ItemStyle-HorizontalAlign="Left" meta:resourcekey="BoundFieldResource2" />
            <asp:BoundField DataField="CodicePDR" HeaderText="PDR" SortExpression="CodicePDR" ItemStyle-HorizontalAlign="Left" meta:resourcekey="BoundFieldResource2" />
         </Columns>
        <RowStyle Height="25px" BackColor="#EEEEEE" ForeColor="Black"  />
    </asp:GridView>




<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"
    SortParameterName="??????" 
        SelectCountMethod="SelectCountForGetList"
        OnSelecting="odsPDR_Selecting">
        <SelectParameters>
            <asp:Parameter Name="PDRCriteria" Type="Object" />
        </SelectParameters>
    </asp:ObjectDataSource>

Thanks
  #17 (permalink)  
Old June 7th, 2009, 03:33 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

If you don't need paging, things will be easier. Simply drop support from the GetList method and remove the Skip().Take() code. Also, remove the attributes from the GridView and ODS related to paging.

Quote:
are many days that I try to find a solution
You can speed things up by providing better and relevant information. Currently, you are not really saying what the (latest) problem is. The same as from a few days ago? Or are you getting another error? If so, which one?

Anyway, I am sure I understand these questionmarks:

SortParameterName="???????"

Copy / paste from my article and you're fine. The SortParameterName is the name of the sort parameter of GetList; once again this is all explained - in detail - in my articles. I am not sure why we need to repeat all of this here. Maybe you need to read the articles again? Or ask questions about them if you don't understand what they are saying? Maybe you need to get a firmer background and understanding of ASP.NET first before you dig into this? Just a thought.

Quote from the article:
Quote:

I set a sortParameterName property on the ObjectDataSource control:

<asp:ObjectDataSource ID="odsContactPersons"
SortParameterName="sortExpression" />

By setting the sortParameterName, ASP.NET knows to what parameter of GetList to pass the sortExpression that it retrieves from the GridView.
There's not a single word of Spanish in there ;-)

So, set it to "sortExpression", the name of the parameter on GetList.

As I also explained in my articles, SelectCountMethod is for paging. If you don't need paging you don't need this method.

Finally, you don't need OnSorting on the GridView. You only need that if you're doing custom sorting at the page level. In your case, the Bll method can do the sorting.

My advise to make this easier: get a firmer grip of the underlying basics of ASP.NET. ASP.NET is not a simple technology. N-Layer design on top of that makes things even more complex. You won't be able to use these concepts to the fullest if you don't have a good understanding of the underlying .NET principles. May I suggest you get yourself a copy of a good book like Professional ASP.NET? You'll find things will go a lot easier with a book like that ;-)

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!
  #18 (permalink)  
Old June 8th, 2009, 06:15 PM
Authorized User
 
Join Date: Mar 2009
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi!

I've read this article



I've deleted pagination references in gridview, and now I've

<asp:GridView ID="gvElenco" runat="server" AutoGenerateColumns="False"
Width="99%" ForeColor="#333333" Font-Names="Verdana" DataKeyNames="CodicePDR"
BorderColor="#999999" BorderStyle="None" BorderWidth="1px" ShowFooter="true" CellPadding="8" GridLines="Vertical">
<Columns>
<asp:BoundField DataField="CodicePDR" HeaderText="Codice" SortExpression="CodicePDR" ItemStyle-HorizontalAlign="Left" meta:resourcekey="BoundFieldResource2" />
<asp:BoundField DataField="DescrizionePDR" HeaderText="Descrizione" SortExpression="DescrizionePDR" ItemStyle-HorizontalAlign="Left" meta:resourcekey="BoundFieldResource2" />
<asp:BoundField DataField="CodicePDR" HeaderText="PDR" SortExpression="CodicePDR" ItemStyle-HorizontalAlign="Left" meta:resourcekey="BoundFieldResource2" />

</Columns>
</asp:GridView>


In my ODS I've:

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


changed GetList as you have written

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();
}
return myCollection;
}



But I see this error:


Errore server nell'applicazione '/'.
--------------------------------------------------------------------------------

Impossibile trovare un metodo non generico 'GetList' per ObjectDataSource 'ods_PDR' che presenti parametri: PDRCriteria, sortExpression.





I hope that you can help me!
  #19 (permalink)  
Old June 8th, 2009, 06:28 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

You still have paging code, you still have a SelectCountMethod setting, you still have paging paramaters in the GetList method.

Also, can you translate the erorr message? I think it says "can't find a method that accepts PDRCriteria, sortExpression", which makes sense as you still have the paging parameters in there.

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!

Last edited by Imar; June 8th, 2009 at 06:43 PM.
  #20 (permalink)  
Old June 9th, 2009, 06:46 AM
Authorized User
 
Join Date: Mar 2009
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Now I don't see errors


<asp:GridView ID="gvElenco" runat="server" AutoGenerateColumns="False"
Width="99%" ForeColor="#333333" Font-Names="Verdana" DataKeyNames="CodicePDR"
BorderColor="#999999" BorderStyle="None" BorderWidth="1px" ShowFooter="true" CellPadding="8" GridLines="Vertical">
<Columns>
<asp:BoundField DataField="CodicePDR" HeaderText="Codice" SortExpression="CodicePDR" ItemStyle-HorizontalAlign="Left" meta:resourcekey="BoundFieldResource2" />
<asp:BoundField DataField="DescrizionePDR" HeaderText="Descrizione" SortExpression="DescrizionePDR" ItemStyle-HorizontalAlign="Left" meta:resourcekey="BoundFieldResource2" />
<asp:BoundField DataField="CodicePDR" HeaderText="PDR" SortExpression="CodicePDR" ItemStyle-HorizontalAlign="Left" meta:resourcekey="BoundFieldResource2" />

</Columns>
</asp:GridView>


In my ODS I've:

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


changed GetList as you have written

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));
}

return myCollection;
}

I've added AllowSorting = "true" in grid view... for allow me to view links in the gridview header.

... I don't see errors but when I click on columns I see that page refresh but items are not sorted
 


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 05:42 PM.


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