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

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

May 18th, 2009, 05:17 PM
|
|
Authorized User
|
|
Join Date: Mar 2009
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I've read the article ... but I don't know where is error in my page!!
Can send me a suggestion?
Thanks
|
|

May 19th, 2009, 06:30 AM
|
|
Authorized User
|
|
Join Date: Mar 2009
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

May 20th, 2009, 06:14 PM
|
|
Authorized User
|
|
Join Date: Mar 2009
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
There isn't a solution?? :-(((
|
|

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

May 24th, 2009, 09:53 AM
|
|
Authorized User
|
|
Join Date: Mar 2009
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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 sender, ObjectDataSourceSelectingEventArgs e) { AttivitaCriteria attivitaCriteria = new AttivitaCriteria();
if(tbRicercaDescrizioneAttivita.Text == "") attivitaCriteria.DescrizioneAttivita = null; else attivitaCriteria.DescrizioneAttivita = tbRicercaDescrizioneAttivita.Text;
e.InputParameters["AttivitaCriteria"] = attivitaCriteria; }
|
|

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

May 29th, 2009, 04:10 PM
|
|
Authorized User
|
|
Join Date: Mar 2009
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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;
}
|
|
 |