RiaGridView - Getting started
Posted by - NA - on 16 March 2009 08:54 AM
|
|
Placing the RiaGridView Control on the Web Page
Another way is to convert the GridView control (that already is on your page) into RiaGridView: simply substitute the “asp” tag prefix for “rs” and the “GridView” tag name for “RiaGridView” and add the following line after the “<%@ Page … %>” line of your apsx page: <%@ Register assembly="RadarSoft.Web.Essential.Grid" namespace="RadarSoft.Web.Essential.Grid" tagprefix="rs" %>Functions of the RiaGridView ControlThe RiaGridView allows displaying data from the data source on a web page in the form of a table, as well as selecting, sorting and editing them. It is based on both ASP.NET and Silverlight technologies, by introducing the Silverlight application into GridView, an ASP.NET component. This allows using the capabilities of the Visual Studio environment for tuning the settings of the RiaGridView control. Functional Capabilities of GridView realized in the RiaGridView Control:
Functional Capabilities of GridView not realized in the RiaGridView Control:
New Functional Capabilities of the RiaGridView Control:
Column FieldsEach column in the RiaGridView control is represented by a DataControlField object. You can manipulate the display of the column fields in RiaGridView control only manually, since the AutoGenerateColumns property is not realized. You can define your own collection of column fields. Different types of column fields define their characteristics in the control. Types of Column Fields, Used in the RiaGridView Control:BoundFieldDisplays the value of a field in the database. By default, this is the standard column type for the RiaGridView control. ButtonFieldDisplays a button for each record in the RiaGridView control. This allows you to create a column of custom control elements – buttons. CheckBoxFieldDisplays a flag for each record in the RiaGridView control. This column field is typically used for displaying fields with logical values. HyperLinkFieldDisplays the value of a field in the database as a hyperlink. It allows you to bind a field to an URL-address of a hyperlink. ImageFieldDisplays an image for each record in the RiaGridView control. Setting the RiaGridView ControlThe basic settings of the RiaGridView control, such as the declarative definition of the column field collection, binding to data and assigning the properties’ values to provide the functional capabilities, are tuned the same way as in GridView. The properties of the GridView control that are not available in the RiaGridView are not displayed in the properties’ window. The RiaGridView control realizes the RowCommand event that is executed upon pressing any of the record control buttons (‘add’ or ‘delete’). ExampleThe example code demonstrates using the RiaGridView control for displaying the values of the Customers table from Microsoft Access database from the OLAPDemo3.mdb file. The values are extracted with the AccessDataSource control. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <%@ Register assembly="RadarSoft.Essential.Web" namespace="RadarSoft.Essential.Web" tagprefix="rs" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title> </head> <body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <br /> <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/OLAPDemo.mdb" SelectCommand="SELECT CustomerID, City, ImageField, BoolField, HyperLinkField FROM CustomersCoppy" DeleteCommand="DELETE FROM [CustomersCoppy] WHERE CustomerID = ?" InsertCommand="INSERT INTO CustomersCoppy(CustomerID, City, Boolfield, ImageField, HyperLinkField) VALUES (@CustomerID, @City, @Boolfield, @ImageField, @HyperLinkField)" UpdateCommand="UPDATE CustomersCoppy SET City = ?, ImageField = ?, BoolField = ?, HyperLinkField = ? WHERE (CustomerID = ?)"> </asp:AccessDataSource> <br /> <rs:RiaGridView ID="RiaGridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" BackColor="#CCFFFF" BackImageUrl="~/Images/eval.png" CellPadding="0" DataKeyNames="CustomerID" DataSourceID="AccessDataSource1" Height="300px" IsPagingEnable="True" IsSortEnable="True" OnRowCommand="RiaGridView1_RowCommand" RowCount="10" ShowFooter="True" SortType="ASC" UseAccessibleHeader="False" Width="600px" AccessKey="" Caption="" CssClass="" EnableViewState="False" GridLines="None" SelectedIndex="0" SkinID="" ToolTip=""> <PagerSettings Mode="NumericFirstLast" /> <Columns> <asp:BoundField ApplyFormatInEditMode="True" DataField="CustomerID" FooterText="CustomerID" HeaderText="CustomerID" ReadOnly="True" SortExpression="CustomerID" /> <asp:BoundField DataField="City" HeaderText="City" HtmlEncode="False" HtmlEncodeFormatString="False" SortExpression="City" /> <asp:CheckBoxField DataField="BoolField" HeaderText="BoolField" SortExpression="BoolField" /> <asp:ImageField AlternateText="alternateText" DataImageUrlField="ImageField" DataImageUrlFormatString="~/Images/{0}" HeaderText="ImageColumn" NullDisplayText="Empty" SortExpression="City"> </asp:ImageField> <asp:HyperLinkField DataNavigateUrlFields="HyperLinkField" DataNavigateUrlFormatString="http://silverlight.net/{0}" DataTextField="City" DataTextFormatString="LinkName: {0}" HeaderText="HeaderLink" SortExpression="City" Target="_blank" Text="Link" /> <asp:ButtonField ButtonType="Button" CommandName="sort" DataTextField="City" DataTextFormatString="Button: {0}" HeaderText="ButtonField" ImageUrl="~/Images/Star.png" SortExpression="CustomerID" Text="Button" /> </Columns> </rs:RiaGridView> <br /> </div> </form> </body> </html> | |
|