CodeSmith Community
Your Code. Your Way. Faster!

Atlas example with GridView Paging, Sorting and inline Update/Delete

Latest post 12-06-2007 6:07 AM by swin. 30 replies.
  • 06-24-2006 3:41 PM

    • bdiaz
    • Top 10 Contributor
    • Joined on 02-20-2006
    • Houston, TX
    • Posts 504
    • Points 15,290

    Atlas example with GridView Paging, Sorting and inline Update/Delete

    It has been a while since I posted my last example, but we have been busy working on bug fixes for the beta release.  With that in mind, I wanted to put together a sample that would show an Atlas enabled GridView that is bound to one of the new strongly-typed data source controls.

    Please note, this sample requires the latest code from SVN (rev 231).


    Bobby Diaz ------------------------------------------ Member of the .NetTiers team http://www.nettiers.com ------------------------------------------
    • Post Points: 90
  • 06-24-2006 3:51 PM In reply to

    • bdiaz
    • Top 10 Contributor
    • Joined on 02-20-2006
    • Houston, TX
    • Posts 504
    • Points 15,290

    Re: Atlas example with GridView Paging, Sorting and inline Update/Delete

    First, create a new page and add the following GridView control:

    <asp:GridView ID="GridView1" AutoGenerateColumns="false" runat="server"
       Font-Names="Verdana, Arial" Font-Size="12px" BorderColor="#cccccc" BorderWidth="1" CellPadding="3" CellSpacing="1"
       DataSourceID="CustomersDataSource1" DataKeyNames="CustomerID" PageSize="10" AllowPaging="true" AllowSorting="true">
       <Columns>
          <asp:CommandField ShowEditButton="True" />
          <asp:BoundField DataField="CustomerID" HeaderText="Cust #" SortExpression="CustomerID" />
          <asp:BoundField DataField="CompanyName" HeaderText="Company" SortExpression="CompanyName" />
          <asp:BoundField DataField="ContactTitle" HeaderText="Title" SortExpression="ContactTitle" />
          <asp:BoundField DataField="ContactName" HeaderText="Name" SortExpression="ContactName" />
          <asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
          <asp:BoundField DataField="Region" HeaderText="Region" SortExpression="Region" />
          <asp:BoundField DataField="PostalCode" HeaderText="Postal Code" SortExpression="PostalCode" />
          <asp:BoundField DataField="Country" HeaderText="Country" SortExpression="Country" />
          <asp:CommandField ShowDeleteButton="true" />
       </Columns>
    </
    asp:GridView>


    Next, add the CustomersDataSource control to your page:

    <data:CustomersDataSource ID="CustomersDataSource1" runat="server"
       SelectMethod="GetPaged" EnablePaging="true" EnableSorting="true"/>

    And you should have a functional GridView with paging and sorting!


    Bobby Diaz ------------------------------------------ Member of the .NetTiers team http://www.nettiers.com ------------------------------------------
    • Post Points: 30
  • 06-24-2006 4:02 PM In reply to

    • bdiaz
    • Top 10 Contributor
    • Joined on 02-20-2006
    • Houston, TX
    • Posts 504
    • Points 15,290

    Re: Atlas example with GridView Paging, Sorting and inline Update/Delete

    Now we want to add a filter to our page to demonstrate a new feature to NetTiers:

    <table border="0" width="310" style="margin-bottom:10px;">
    <
    tr>
       <td>
          <asp:Label ID="CountryLabel" AssociatedControlID="CountryList" runat="server"
             
    Text="Country:" Font-Bold="true" Font-Names="Verdana" Font-Size="12px" />
       </td>
       <td>
          <asp:DropDownList ID="CountryList" AutoPostBack="true" runat="server">
                <asp:ListItem Value="">All</asp:ListItem>
                <asp:ListItem>Brazil</asp:ListItem>
                <asp:ListItem>Canada</asp:ListItem>
                <asp:ListItem>France</asp:ListItem>
                <asp:ListItem>Germany</asp:ListItem>
                <asp:ListItem>Italy</asp:ListItem>
                <asp:ListItem>Mexico</asp:ListItem>
                <asp:ListItem>Spain</asp:ListItem>
                <asp:ListItem>UK</asp:ListItem>
                <asp:ListItem>USA</asp:ListItem>
                <asp:ListItem>Venezuela</asp:ListItem>
          </asp:DropDownList>
       </td>
       <td align="right">
          <asp:Label ID="TimeLabel" runat="server" Font-Names="Verdana" Font-Size="10px"><%= DateTime.Now %/></asp:Label>
       </td>
    </
    tr>
    </
    table>

    Next, change the data source control to add a parameter for the whereClause parameter of the GetPaged method:

    <data:CustomersDataSource ID="CustomersDataSource1" runat="server"
       SelectMethod="GetPaged" EnablePaging="true" EnableSorting="true">
       <Parameters>
          <data:SqlParameter Name="WhereClause" UseParameterizedFilters="false">
             <Filters>
                <data:CustomersFilter Column="Country" ControlID="CountryList" />
             </Filters>
          </data:SqlParameter>
       </Parameters>
    </
    data:CustomersDataSource>

    The SqlParameter allows you to define external filter controls that will be combined to generate the filter expression.

    Update (11-Aug-2006): a new property has been added to the SqlParameter object to provide support for the New Query Builder Classes.


    Bobby Diaz ------------------------------------------ Member of the .NetTiers team http://www.nettiers.com ------------------------------------------
    • Post Points: 35
  • 06-24-2006 4:28 PM In reply to

    • bdiaz
    • Top 10 Contributor
    • Joined on 02-20-2006
    • Houston, TX
    • Posts 504
    • Points 15,290

    Re: Atlas example with GridView Paging, Sorting and inline Update/Delete

    Now we can add the magic!  Make sure you have a reference to the Atlas Script Manager:

    <atlas:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server" />

    We want to wrap the GridView control with an UpdatePanel:

    <atlas:UpdatePanel ID="GridPanel" Mode="Conditional" runat="server">
       <
    ContentTemplate>

          <!-- GridView declaration goes here -->

       
    </ContentTemplate>
       <
    Triggers>
          <atlas:ControlEventTrigger ControlID="CountryList" EventName="SelectedIndexChanged" />
       </
    Triggers>
    </
    atlas:UpdatePanel>

    Notice that the trigger is tied to the CountryList control so that the GridView is updated every time the selected country is changed.


    Bobby Diaz ------------------------------------------ Member of the .NetTiers team http://www.nettiers.com ------------------------------------------
    • Post Points: 35
  • 06-24-2006 4:36 PM In reply to

    • bdiaz
    • Top 10 Contributor
    • Joined on 02-20-2006
    • Houston, TX
    • Posts 504
    • Points 15,290

    Re: Atlas example with GridView Paging, Sorting and inline Update/Delete

    There you have it, a quick example of how you can use Atlas, or any Ajax library, along with the .netTiers generated classes to deliver a responsive user interface.

    Please see the attached file for the complete code presented in this example.  Note that there is no code-behind page needed!

    Enjoy.

    Bobby Diaz ------------------------------------------ Member of the .NetTiers team http://www.nettiers.com ------------------------------------------
    • Post Points: 95
  • 07-09-2006 12:15 AM In reply to

    Re: Atlas example with GridView Paging, Sorting and inline Update/Delete

    Hi,you keep mentioning latest revision for EDS, and also mike templates,where is this located(SVN)..please guide mee
    thks

    • Post Points: 35
  • 07-11-2006 10:53 AM In reply to

    • bdiaz
    • Top 10 Contributor
    • Joined on 02-20-2006
    • Houston, TX
    • Posts 504
    • Points 15,290

    Re: Atlas example with GridView Paging, Sorting and inline Update/Delete

    Take a look at the following thread for instructions on checking out the latest code from SVN:

    http://community.codesmithtools.com/forums/thread/10943.aspx

    The latest and greatest can be found under: /templates/netTiers2/0.9.5/

    Thanks.

    Bobby Diaz ------------------------------------------ Member of the .NetTiers team http://www.nettiers.com ------------------------------------------
    • Post Points: 35
  • 07-18-2006 12:06 PM In reply to

    • joewoo
    • Not Ranked
    • Joined on 07-18-2006
    • Posts 1
    • Points 35

    Re: Atlas example with GridView Paging, Sorting and inline Update/Delete

    I'm relatively new to .NET, so be easy on me :). Just curious, is there any way to do the sorting without .netTiers and just use .NET and Atlas?  Thanks.
    • Post Points: 35
  • 07-18-2006 3:08 PM In reply to

    • bdiaz
    • Top 10 Contributor
    • Joined on 02-20-2006
    • Houston, TX
    • Posts 504
    • Points 15,290

    Re: Atlas example with GridView Paging, Sorting and inline Update/Delete

    Take a look at this blog post by Scott Guthrie.  It is an older post, but if you browse his site, you will find tons of information!

    http://weblogs.asp.net/scottgu/archive/2005/12/26/433997.aspx

    Hope that helps.

    Bobby Diaz ------------------------------------------ Member of the .NetTiers team http://www.nettiers.com ------------------------------------------
    • Post Points: 5
  • 07-19-2006 11:31 PM In reply to

    Re: Atlas example with GridView Paging, Sorting and inline Update/Delete

    bdiaz wrote:
    There you have it, a quick example of how you can use Atlas, or any Ajax library, along with the .netTiers generated classes to deliver a responsive user interface.

    Please see the attached file for the complete code presented in this example.  Note that there is no code-behind page needed!

    Enjoy.

    wrong attached file? I saw a two line text file.

     

    • Post Points: 5
  • 07-20-2006 6:26 AM In reply to

    • Alex
    • Top 10 Contributor
    • Joined on 07-26-2005
    • Australia, Canberra
    • Posts 526
    • Points 10,645

    Re: Atlas example with GridView Paging, Sorting and inline Update/Delete

    Bobby, this is awesome! I've just noticed that now each table has it is own TableDataSource control! Is it true that they already has the same design support as ObjectDataSource?
    Best regards,
    Alex.
    • Post Points: 35
  • 07-20-2006 8:59 AM In reply to

    • bdiaz
    • Top 10 Contributor
    • Joined on 02-20-2006
    • Houston, TX
    • Posts 504
    • Points 15,290

    Re: Atlas example with GridView Paging, Sorting and inline Update/Delete

    Alex,

    Good to see that you had a chance to check out the new controls.  The generated data source controls do have design-time support, but it is not yet as full featured as the built-in controls.  We plan on adding more to this functionality as time permits.

    Any suggestions are welcome!

    Bobby Diaz ------------------------------------------ Member of the .NetTiers team http://www.nettiers.com ------------------------------------------
    • Post Points: 35
  • 07-20-2006 11:30 AM In reply to

    • Alex
    • Top 10 Contributor
    • Joined on 07-26-2005
    • Australia, Canberra
    • Posts 526
    • Points 10,645

    Re: Atlas example with GridView Paging, Sorting and inline Update/Delete

    Cool, I'm looking forward this! I've looked briefly at PetShop2 sample, but was not able to run it, because there are several issues with solution and db cannot be attached because of missing LDF file. Also, I've noticed that web admin controls is different than in .NetTiers 0.9.2 so I wonder how I can generate the same ones? Also, atlas libs is missing in PetShop sample...
    Best regards,
    Alex.
    • Post Points: 5
  • 07-21-2006 4:54 AM In reply to

    • Gonzo
    • Top 75 Contributor
    • Joined on 07-21-2006
    • Glasgow, Scotland
    • Posts 57
    • Points 1,480

    Re: Atlas example with GridView Paging, Sorting and inline Update/Delete

    EDIT:

    Please ignore me, it is Friday here in "sunny" Scotland and I must have been half asleep when i posted this.

    <pages>
    <
    controls>
    <
    add namespace="Microsoft.Web.UI" assembly="Microsoft.Web.Atlas" tagPrefix="atlas"/>
    <
    add namespace="Microsoft.Web.UI.Controls" assembly="Microsoft.Web.Atlas" tagPrefix="atlas"/>
    <
    add tagPrefix="data" assembly="AtlasTest.NetTiers.Web" namespace="AtlasTest.NetTiers.Web.Data"/>
    <
    add tagPrefix="data" assembly="AtlasTest.NetTiers.Web" namespace="AtlasTest.NetTiers.Web.UI"/>
    </
    controls>
    </
    pages>

    DOUGH!!! Big Smile [:D]

    David

    Origional Post:

    "Please excuse me if the answer to my question is obvious, but i have recently started working with NetTiers and Atlas for my DAL and AJAX functionality instead of writing my own.

    My question is on your example, as below, you are using "<data:".  Where does this come from?  Is it your own custom object or am i completely misunderstanding your example?

    Thanks in advance, David

    <data:CustomersDataSource ID="CustomersDataSource1" runat="server"
       SelectMethod="GetPaged" EnablePaging="true" EnableSorting="true"/>"

    David Lawton Hyperion Technologies Ltd (UK)
    • Post Points: 5
  • 08-11-2006 3:14 AM In reply to

    • jamesm
    • Not Ranked
    • Joined on 08-11-2006
    • Posts 1
    • Points 35

    Re: Atlas example with GridView Paging, Sorting and inline Update/Delete

    I am using the 8/8/2006 release and I cannot not get your sample to fly.

    On page load I get a:

    Unable to cast object of type 'Northwind.Data.SqlFilterParameterCollection' to type 'System.String'.

    Source Error:

    Line 1192:			
    Line 1193:			// known parameters
    Line 1194:			WhereClause = (String) values["WhereClause"];
    Line 1195:
    Line 1196:			if ( values["OrderBy"] != null )

    Source File: C:\NetTiers\Northwind\Northwind.Web\Data\BaseDataSource.cs    Line: 1194

    I tried it first with my progrject, then did a new Norwthwind to check.

    I did not get a prior release to see if that solved it.

    thanks,

    jamesm

    • Post Points: 35
Page 1 of 3 (31 items) 1 2 3 Next > | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems