- Inbuilt filter
- link column
- client side sorting
- edit and delete buttons in rows
- responding to events
- customizing grid while it load.
(%@ Register TagPrefix="igtbl" Namespace="Infragistics.WebUI.UltraWebGrid" Assembly="Infragistics.WebUI.UltraWebGrid.v6.3, Version=6.3.20063.53, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" %)
(!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" )
(HTML)
(HEAD)
(title)testpage(/title)
(meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR")
(meta content="C#" name="CODE_LANGUAGE")
(meta content="JavaScript" name="vs_defaultClientScript")
(meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema")
(LINK href="/ig_common/20063/Styles/Office2007Silver/ig_WebGrid.css " type="text/css"
rel="Stylesheet")
(/HEAD)
(body MS_POSITIONING="GridLayout" XMLNS:igtbl="http://schemas.infragistics.com/ASPNET/WebControls/UltraWebGrid")
(form id="Form1" method="post" runat="server")
(table border="1" )
(tr)
(td)
(igtbl:ultrawebgrid id="UltraWebGrid1"
runat="server" ImageDirectory="/ig_common/20063/Styles/Office2007Silver/WebGrid/")
(DisplayLayout CompactRendering="False" StationaryMarginsOutlookGroupBy="True" AllowSortingDefault="OnClient"
RowHeightDefault="20px" Version="4.00" ViewType="OutlookGroupBy" SelectTypeRowDefault="Extended"
BorderCollapseDefault="Separate" Name="UltraWebGrid1" CellClickActionDefault="RowSelect")
(AddNewBox)
(Style CssClass="igwgAddNewBoxSilver2k7")(/Style)
(ButtonStyle CssClass="igwgAddNewBtnSilver2k7")(/ButtonStyle)
(/AddNewBox)
(Pager)
(Style CssClass="igwgPgrSilver2k7")(/Style)
(/Pager)
(HeaderStyleDefault CssClass="igwgHdrSilver2k7")(/HeaderStyleDefault)
(FormulaErrorStyleDefault CssClass="igwgFormulaErrSilver2k7")(/FormulaErrorStyleDefault)
(GroupByRowStyleDefault CssClass="igwgGrpRowSilver2k7")(/GroupByRowStyleDefault)
(RowSelectorStyleDefault CssClass="igwgRowSlctrSilver2k7")(/RowSelectorStyleDefault)
(FrameStyle CssClass="igwgFrameSilver2k7")(/FrameStyle)
(FilterOptionsDefault DropDownRowCount="15")
(FilterHighlightRowStyle CssClass="igwgFltrRowHiLtSilver2k7")(/FilterHighlightRowStyle)
(FilterDropDownStyle CssClass="igwgFltrDrpDwnSilver2k7")(/FilterDropDownStyle)
(/FilterOptionsDefault)
(FooterStyleDefault CssClass="igwgFooterSilver2k7")(/FooterStyleDefault)
(ActivationObject BorderColor="181, 196, 223")
(BorderDetails WidthLeft="0px" WidthRight="0px")(/BorderDetails)
(/ActivationObject)
(GroupByBox)
(Style CssClass="igwgGrpBoxSilver2k7")(/Style)
(BandLabelStyle CssClass="igwgGrpBoxBandLblSilver2k7")(/BandLabelStyle)
(/GroupByBox)
(Images ImageDirectory="/ig_common/20063/Styles/Office2007Silver/WebGrid/" /)
(RowExpAreaStyleDefault CssClass="igwgRowExpSilver2k7")(/RowExpAreaStyleDefault)
(SelectedHeaderStyleDefault CssClass="igwgHdrSelSilver2k7")(/SelectedHeaderStyleDefault)
(FixedHeaderStyleDefault CssClass="igwgHdrFxdSilver2k7")(/FixedHeaderStyleDefault)
(EditCellStyleDefault CssClass="igwgCellEdtSilver2k7")(/EditCellStyleDefault)
(FixedFooterStyleDefault CssClass="igwgFtrFxdSilver2k7")(/FixedFooterStyleDefault)
(SelectedGroupByRowStyleDefault CssClass="igwgGrpRowSelSilver2k7")(/SelectedGroupByRowStyleDefault)
(SelectedRowStyleDefault CssClass="igwgRowSelSilver2k7")(/SelectedRowStyleDefault)
(RowAlternateStyleDefault CssClass="igwgRowAltSilver2k7")(/RowAlternateStyleDefault)
(RowStyleDefault CssClass="igwgRowSilver2k7")
(Padding Left="3px")(/Padding)
(/RowStyleDefault)
(FixedCellStyleDefault CssClass="igwgCellFxdSilver2k7")(/FixedCellStyleDefault)
(/DisplayLayout)
(Bands)
(igtbl:UltraGridBand)(/igtbl:UltraGridBand)
(/Bands)
(/igtbl:ultrawebgrid)
(/td)
(/tr)
(tr)
(td)(asp:button id="Button1" runat="server"
Text="Get value")(/asp:button)
(asp:button id="Button2" runat="server"
Text="Load")(/asp:button) (/td)
(/tr)
(/table)
(/form)
(/body)
(/HTML)
c# page
#region using
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Text;
using BMSQBInterface;
using bmsFramework.MyAccount;
using Infragistics.WebUI.UltraWebGrid;
#endregion
namespace bms
{
///
/// Summary description for testpage.
///
public class testpage : System.Web.UI.Page
{
protected BMSQBServer bmsQBServer = null;
protected DBConnection dbc;
protected Infragistics.WebUI.UltraWebGrid.UltraWebGrid UltraWebGrid1;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Button Button2;
protected System.Data.SqlClient.SqlConnection myConn;
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
Button2_Click(sender, e); // simulates data load.
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.UltraWebGrid1.InitializeRow += new Infragistics.WebUI.UltraWebGrid.InitializeRowEventHandler(this.UltraWebGrid1_InitializeRow);
this.UltraWebGrid1.InitializeLayout += new Infragistics.WebUI.UltraWebGrid.InitializeLayoutEventHandler(this.UltraWebGrid1_InitializeLayout);
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Button2.Click += new System.EventHandler(this.Button2_Click);
this.Load += new System.EventHandler(this.Page_Load);
this.UltraWebGrid1.ClickCellButton += new ClickCellButtonEventHandler(UltraWebGrid1_ClickCellButton); //handles edit and delete button click events.
}
#endregion
private void UltraWebGrid1_InitializeLayout(object sender, Infragistics.WebUI.UltraWebGrid.LayoutEventArgs e)
{
UltraWebGrid1.DisplayLayout.AllowSortingDefault = Infragistics.WebUI.UltraWebGrid.AllowSorting.OnClient; // allow client sorting.
UltraWebGrid1.DisplayLayout.HeaderClickActionDefault = Infragistics.WebUI.UltraWebGrid.HeaderClickAction.SortSingle; // only sort single column.
UltraWebGrid1.DisplayLayout.SelectedRowStyleDefault.BackColor = Color.LightSteelBlue; // row selecter color.
//Name column for employee
UltraWebGrid1.Columns[1].Header.Style.HorizontalAlign = HorizontalAlign.Left;
UltraWebGrid1.Columns[1].Header.Caption = "Employee Name"; // default value from db column is name.
UltraWebGrid1.Columns[3].CellStyle.HorizontalAlign = HorizontalAlign.Center;
UltraWebGrid1.Columns[4].CellStyle.HorizontalAlign = HorizontalAlign.Center;
//Edit button.
UltraWebGrid1.Columns[7].Type= ColumnType.Button;
UltraWebGrid1.Columns[7].CellButtonDisplay=CellButtonDisplay.Always;
UltraWebGrid1.Columns[7].CellButtonStyle.Font.Name = "Verdana";
UltraWebGrid1.Columns[7].CellButtonStyle.Font.Size = FontUnit.Point(7);
UltraWebGrid1.Columns[7].CellButtonStyle.BackColor = Color.Lavender;
UltraWebGrid1.Columns[7].CellButtonStyle.Width = Unit.Pixel(50);
UltraWebGrid1.Columns[7].CellButtonStyle.Height = Unit.Pixel(20);
UltraWebGrid1.Columns[7].CellStyle.Padding.Left=new Unit("5px");
UltraWebGrid1.Columns[7].CellStyle.Padding.Right=new Unit("5px");
//Delete button.
UltraWebGrid1.Columns[8].Type= ColumnType.Button;
UltraWebGrid1.Columns[8].CellButtonDisplay=CellButtonDisplay.Always;
UltraWebGrid1.Columns[8].CellButtonStyle.Font.Name = "Verdana";
UltraWebGrid1.Columns[8].CellButtonStyle.Font.Size = FontUnit.Point(8);
UltraWebGrid1.Columns[8].CellButtonStyle.BackColor = Color.Lavender;
UltraWebGrid1.Columns[8].CellButtonStyle.Width = Unit.Pixel(70);
UltraWebGrid1.Columns[8].CellButtonStyle.Height = Unit.Pixel(20);
UltraWebGrid1.Columns[8].CellStyle.Padding.Left=new Unit("5px");
UltraWebGrid1.Columns[8].CellStyle.Padding.Right=new Unit("5px");
//Hide the key column..id.
UltraWebGrid1.Columns[0].Hidden = true;
UltraWebGrid1.Width = Unit.Empty;
UltraWebGrid1.Height = Unit.Empty;
UltraWebGrid1.DisplayLayout.FrameStyle.CustomRules = "table-layout:auto";
}
//To make a column values as link.
private void UltraWebGrid1_InitializeRow(object sender, Infragistics.WebUI.UltraWebGrid.RowEventArgs e)
{
e.Row.Cells[1].TargetURL = "http://www.google.com/search?hl=en&q=" + e.Row.Cells[0].Value.ToString();
}
//Handles button clicks inside the grid.
private void UltraWebGrid1_ClickCellButton(object sender, Infragistics.WebUI.UltraWebGrid.CellEventArgs e)
{
string strDBKey = UltraWebGrid1.DisplayLayout.ActiveRow.Cells[0].Text.ToString();
bool bdelete = UltraWebGrid1.DisplayLayout.ActiveRow.Cells[8].Activated; // is true when del button is clicked.
bool bedit = UltraWebGrid1.DisplayLayout.ActiveRow.Cells[7].Activated; // is true when edit button is clicked.
Session.Contents["ContactID"] = Int32.Parse(strDBKey);
if(bedit)
{
Response.Redirect("edit_account/Contact.aspx", true);
}
}
//Get row values when an external button click happens
private void Button1_Click(object sender, System.EventArgs e)
{
string strDBKey = UltraWebGrid1.DisplayLayout.ActiveRow.Cells[0].Text.ToString();
Response.Write("key is " + strDBKey.ToString());
}
private void Button2_Click(object sender, System.EventArgs e)
{
dbc = new DBConnection();
string strConnInfo = Application.Contents["ConnectionInfo"].ToString();
myConn = dbc.OpenDatabase(strConnInfo);
GridDBInterface ogd = new GridDBInterface();
//ogd.FillContactGrid(UltraWebGrid1,myConn,400,1,0);
DataSet ds1 = new DataSet();
ds1 = ogd.GetFormFilingHistory(myConn,400,1,0);
//Add edit and delete button to Dataset.
DataColumn hide=new DataColumn("Edits");
hide.DefaultValue = "Edit";
ds1.Tables[0].Columns.Add(hide);
DataColumn del=new DataColumn("Deletes");
del.DefaultValue = "Delete";
ds1.Tables[0].Columns.Add(del);
UltraWebGrid1.DataSource = ds1.Tables[0].DefaultView;
UltraWebGrid1.DataBind();
}
}
}
ds method:
public DataSet GetFormFilingHistory(System.Data.SqlClient.SqlConnection argConn,int CustomerID,short InternalContact,short Inactive)
{
string strQuery = "usp_xyz";
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(strQuery,argConn);
da.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure;
da.SelectCommand.CommandTimeout = 0;
AddIDParam(da.SelectCommand, "@Customer_ID",CustomerID);
AddIDIntParam(da.SelectCommand, "@InternalContact",InternalContact);
AddIDIntParam(da.SelectCommand, "@Inactive",Inactive);
da.Fill(ds, "Contacts");
return ds;
}
No comments:
Post a Comment