|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionThe Using the codeThe complete code and assemblies are attached with this article. You can download the MrllControlLib.dll and add a reference to it in your project. Once you add the control to your page, you can assign various properties in order to control the attribute set in the context menu. The following are some of the properties exposed:
Note that if you have assigned protected void gv1_PageSizeChange(object sender, PageSizeChangeEventArgs e)
{
gv1.PageSize= e.NewPageSize;
gv1.PageIndex = 0;
BindGrid();
}
The rest of the events like About the codeThe custom gridview control inherits from the .NET protectedd override OnRowCreated(GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Pager)
{
e.Row.Cells[0].Controls.Clear();
//Code to Add various Dropdown
//Add control to Row
// oOutertab is table containg all dropdown and Lable
e.Row.Cells[0].Controls.Add(oOutertab);
}
}
Now, the problem is when there is only one page, the protected override void OnRowCreated(GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
if (PageCount ==1)
{
GridViewRow PagerRow = base.CreateRow(-1, -1,
DataControlRowType.Pager, DataControlRowState.Normal);
//Add Your container of controls in this New row
PagerRow.Cells.Add(new TableCell());
PagerRow.Cells[0].Controls.Add(oTab);
PagerRow.Cells[0].ColumnSpan = this.Columns.Count;
//Add the New row at Position 0 of GrdView
Table grid = (Table)this.Controls[0];
grid.Rows.AddAt(0, PagerRow);
}
}
}
Now, there is another issue. Once you add a row at position zero, then it will have the style of the header-template, since we added this row while the header row was getting created. So, to apply the correct styling on the correct row, we need to assign GridViewRow PagerRow = base.CreateRow(-1, -1,
DataControlRowType.Pager, DataControlRowState.Normal);
if (this.CustomPagerCssClass != string.Empty)
PagerRow.CssClass = this.CustomPagerCssClass;
if (this.HeaderStyle.CssClass != string.Empty)
e.Row.CssClass = this.HeaderStyle.CssClass;
//Now Add Pager Row at Position zero
Table grid = (Table)this.Controls[0];
grid.Rows.AddAt(0, PagerRow);
|
||||||||||||||||||||||