Welcome to the CodeSmith Community!

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

.netTiers

A description has not yet been added to this group.

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

  • rated by 0 users
  • This post has 30 Replies |
  • 8 Followers
  • atlas.gif
    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 ------------------------------------------
  • 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 ------------------------------------------
  • 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 ------------------------------------------
  • 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 ------------------------------------------
  • Default.txt
    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 ------------------------------------------
  • Hi,you keep mentioning latest revision for EDS, and also mike templates,where is this located(SVN)..please guide mee
    thks

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

     

  • 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.
  • 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 ------------------------------------------
  • 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.
  • 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)
  • 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

Page 1 of 3 (31 items) 123