Can someone post an example of a whdg with manual on demand with one child grid having one of the columns with hyperlinks and behaviors like paging, sorting enabled?
Please dont give me links,I have read through every post and it deosnt seem to help in this particular case
I need an example
Thanks!
Hi dev_here,
I'm just checking if you have resolved your issue.
Hello,
I am attaching the previously attached sample modified with third level sorting.
Let me know if you have any questions.
protected DataTable MyGridChildDt(int myId, int userid)
{ DataAccess.ReportsDB db = new DataAccess.ReportsDB();
DataSet childDs = new DataSet();
DataTable dt = db.GetIPs(myId, this.UserId);
childDs.Tables.Add(dt);
childDs.Tables[0].TableName = "Child";
return childDs.Tables[0];
}
protected DataTable MyGridGrandChildDt(int myId, int userid,string classType)
DataTable dt = db.GetIPDetails(myId, this.UserId, classTypes);
childDs.Tables[0].TableName = "GChild";
protected void MyGrid_RowIslandsPopulating(object sender, Infragistics.Web.UI.GridControls.ContainerRowCancelEventArgs e)
{ //Cancel the default automatic load on demand operation
e.Cancel = true;
switch (e.Row.Level)
{
case 0: BindSecondLevel(e);
break;
case 1: BindThirdLevel(e);
private void BindSecondLevel(Infragistics.Web.UI.GridControls.ContainerRowCancelEventArgs e)
int myId = Int32.Parse(e.Row.Items.FindItemByKey("myIdColumn").Value.ToString());
// Create Container Grid
ContainerGrid childGrid = new ContainerGrid();
e.Row.RowIslands.Add(childGrid);
// Bind Grid
childGrid.AutoGenerateColumns = false;
childGrid.DataKeyFields = "ROW";
childGrid.Level = 1;
BoundDataField iprow = new BoundDataField();
iprow.DataFieldName = "ROW";
iprow.Key = "IPROWColumn";
iprow.Header.Text = "ROW";
iprow.Hidden = true;
BoundDataField classification = new BoundDataField();
classification.DataFieldName = "Classification";
classification.Key = "ClassificationColumn";
classification.Hidden = true;
classification.Header.Text = "Classification";
BoundDataField myId = new BoundDataField();
myId.DataFieldName = "myId";
myId.Key = "myIdColumn";
myId.Hidden = true;
myId.Header.Text = "myId";
BoundDataField high = new BoundDataField();
high.DataFieldName = "High";
high.Key = "HighColumn";
high.Width = Unit.Pixel(60);
high.Header.Text = "High";
high.CssClass = "RiskColumnCssClass";
BoundDataField medium = new BoundDataField();
medium.DataFieldName = "Medium";
medium.Key = "MediumColumn";
medium.Width = Unit.Pixel(60);
medium.Header.Text = "Medium";
medium.CssClass = "RiskColumnCssClass";
childGrid.Columns.Add(iprow);
childGrid.Columns.Add(high); childGrid.Columns.Add(medium);
childGrid.Columns.Add(myId);
childGrid.Columns.Add(classification);
childGrid.Behaviors.CreateBehavior<Sorting>();
childGrid.Behaviors.Sorting.Enabled = true;
childGrid.Behaviors.Sorting.SortedColumns.Add("IPAddressColumn", Infragistics.Web.UI.SortDirection.Descending); childGrid.Behaviors.CreateBehavior<Infragistics.Web.UI.GridControls.Paging>();
childGrid.Behaviors.Paging.Enabled = true;
childGrid.Behaviors.Paging.PagerMode = Infragistics.Web.UI.GridControls.PagerMode.NumericFirstLast;
childGrid.Behaviors.Paging.PageSize = 15;
childGrid.Behaviors.CreateBehavior<Infragistics.Web.UI.GridControls.Filtering>();
childGrid.Behaviors.Filtering.Enabled = true;
private void BindThirdLevel(Infragistics.Web.UI.GridControls.ContainerRowCancelEventArgs e)
if (e.Row.RowIslands.Count == 0)
{ int myId = Int32.Parse(e.Row.Items.FindItemByKey("myIdColumn").Value.ToString());
string classification= e.Row.Items.FindItemByKey("ClassificationColumn").Value.ToString();
childGrid.DataKeyFields = "ExpID";
childGrid.Level = 2;
BoundDataField exposureid = new BoundDataField();
expid.DataFieldName = "ExpID";
expid.Key = "ExpIDColumn";
expid.Header.Text = "Id";
expid.Hidden = true;
BoundDataField risk = new BoundDataField();
risk.DataFieldName = "RiskFactorText";
risk.Key = "RiskFactorTextColumn";
risk.Width = Unit.Pixel(80);
risk.Header.Text = "Risk";
risk.CssClass = "RiskColumnCssClass";
TemplateDataField name = new TemplateDataField();
name.ItemTemplate = new ActionChildItemTemplate();
name.Key = "NameColumn";
name.Header.Text = "Name";
BoundDataField namehidden = new BoundDataField();
namehidden.DataFieldName = "name";
namehidden.Key = "NameColumnHidden";
namehidden.Header.Text = "NameColumn";
namehidden.Hidden = true;
childGrid.Columns.Add(risk);
childGrid.Columns.Add(expid);
childGrid.Columns.Add(name);
childGrid.Columns.Add(namehidden);
//childGrid.Behaviors.Sorting.SortedColumns.Add("RiskFactorTextColumn", Infragistics.Web.UI.SortDirection.Descending); childGrid.Behaviors.CreateBehavior<Infragistics.Web.UI.GridControls.Paging>();
//childGrid.Behaviors.Paging.PagerMode = Infragistics.Web.UI.GridControls.PagerMode.NumericFirstLast;
//childGrid.Behaviors.Paging.PageSize = 15;
} else {
e.Row.RowIslands[0].AutoGenerateColumns = false;
name.Key = "nameColumn";
name.Header.Text = "Exposure";
if (e.Row.RowIslands[0].Columns.FromKey("nameColumn") == null)
{ e.Row.RowIslands[0].Columns.Add(name);
else {
(e.Row.RowIslands[0].Columns["nameColumn"] as TemplateDataField).ItemTemplate = new ActionChildItemTemplate();
namehidden.Key = "nameColumnHidden";
namehidden.Header.Text = "Exposure";
if (e.Row.RowIslands[0].Columns.FromKey("nameColumnHidden") == null)
{ e.Row.RowIslands[0].Columns.Add(namehidden); }
e.Row.RowIslands[0].DataKeyFields = "ExpID";
e.Row.RowIslands[0].Behaviors.Sorting.Enabled = true;
e.Row.RowIslands[0].Behaviors.Paging.Enabled = true;
e.Row.RowIslands[0].Behaviors.Filtering.Enabled = true;
public class ActionChildItemTemplate : ITemplate
{ #region ITemplate Member
public void InstantiateIn(Control container)
{ HyperLink link = new HyperLink();
link.ID = "explink";
link.ForeColor = Color.Blue;
link.Text = ((DataRowView)(((TemplateContainer)container).DataItem)).Row["name"].ToString();
container.Controls.Add(link);
#endregion
protected void MyGrid_RowIslandDataBinding(object sender, RowIslandEventArgs e)
if (e.RowIsland.Level == 1)
int myId = Int32.Parse(e.RowIsland.ParentRow.Items.FindItemByKey("myIdColumn").Value.ToString());
string classType = e.RowIsland.ParentRow.Items.FindItemByKey("ClassificationColumn").Value.ToString();
e.RowIsland.DataKeyFields = "IPROW";
e.RowIsland.DataSource = this.MyGridChildDt(myId, this.UserId);
if (e.RowIsland.Level == 2)
{ int myId = Int32.Parse(e.RowIsland.ParentRow.Items.FindItemByKey("myIdColumn").Value.ToString());
e.RowIsland.DataKeyFields = "ExpID";
e.RowIsland.DataSource = this.MyGridGrandChildDt(myId, this.UserId,classType);
protected void MyGrid_InitializeRow(object sender, Infragistics.Web.UI.GridControls.RowEventArgs e)
{ if (((ContainerGridRecord)e.Row).Level < 2)
((ContainerGridRecord)e.Row).IsEmptyParent = true;
if (e.Row.Items.Grid.DataKeyFields == "ExpID")
//format the name cell and set hyperlink
int exposureId = Int32.Parse(e.Row.Items.FindItemByKey("ExpIDColumn").Value.ToString().ToLower());
//set name detail hyperlink
string pageName = "ReportsDetailsPage.aspx";
string refLink = CriticalWatch.HttpUrlBuilder.BuildUrl("" + "&ExposureId=" + exposureId);
var hprlink = ((HyperLink)e.Row.Items.FindItemByKey("nameColumn").FindControl("explink"));
if (hprlink != null)
hprlink.NavigateUrl = "BLOCKED SCRIPTopenPopupWindow('" + refLink + "','newwin',500,500,'yes');";
} string riskFactor = e.Row.Items.FindItemByKey("RiskFactorTextColumn").Value.ToString();
System.Drawing.Color riskColor = Color.Black;
switch (riskFactor.ToLower()) {
case "high":
riskColor = Color.Red;
e.Row.Items.FindItemByKey("RiskFactorTextColumn").CssClass = "RiskColumnCssClassRed";
case "medium":
riskColor = Color.Orange;
e.Row.Items.FindItemByKey("RiskFactorTextColumn").CssClass = "RiskColumnCssClassOrange";
default:
riskColor = Color.Black;
e.Row.Items.FindItemByKey("RiskFactorTextColumn").CssClass = "RiskColumnCssClassBlack";
Hello dev_here,
If you still need assistance with the matter, please feel free to contact me.
Is it possible to provide a sample reproducing this error, or modify the sample I attached in my previous post to demonstrate the issue. Thank you.