 |
| 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
|
|
|
|

May 29th, 2009, 05:55 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

June 4th, 2009, 06:50 AM
|
|
Authorized User
|
|
Join Date: Mar 2009
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
--
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!!
|
|

June 5th, 2009, 02:42 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

June 5th, 2009, 11:44 AM
|
|
Authorized User
|
|
Join Date: Mar 2009
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

June 7th, 2009, 06:09 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

June 7th, 2009, 01:43 PM
|
|
Authorized User
|
|
Join Date: Mar 2009
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

June 7th, 2009, 02:33 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

June 8th, 2009, 05:15 PM
|
|
Authorized User
|
|
Join Date: Mar 2009
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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!
|
|

June 8th, 2009, 05:28 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
Last edited by Imar; June 8th, 2009 at 05:43 PM..
|
|

June 9th, 2009, 05:46 AM
|
|
Authorized User
|
|
Join Date: Mar 2009
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|
 |