Skip to main content

Posts

Showing posts from July, 2007

How to Add Additional Element to GridView Pager without PagerTemplate

PagerTemplate allows to create any configuration of pager but it also requires custom paging to be implemented. Sometimes built-in paging completely meet all needs but a little modification is reduired, for example, ability to change page size. That can be done within RowCreated event handler.

<asp:GridView ID="GridView1" runat=server AllowPaging="True" OnRowCreated="GridView1_RowCreated" ...
Code behind: protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Pager)
{
DropDownList ddl = new DropDownList();
//adds variants of pager size
ddl.Items.Add("5");
ddl.Items.Add("10");
ddl.AutoPostBack = true;
//selects item due to the GridView current page size
ListItem li = ddl.Items.FindByText(GridView1.PageSize.ToString());
if (li != null)
ddl.SelectedIndex = ddl.Items.IndexOf(li);
ddl.SelectedIndexChanged += new Eve…

Rounded Panel without Images

Panels with rounded borders are widely used in the web site design. So widely that it is hard to add something new. I just try to wrap existing ideas in the form of a web control.

Features: Can be set radius of the circle, back color and border colorWithout images (pure HTML)Only 130 lines of codeEasy to use (see examples below this article)<cc:RoundedPanel ID="RoundedPanel1" runat="server" CssClass="r1" BorderColor="Gold" BackColor="Beige" Radius="9"></cc:RoundedPanel>

I inherit control from WebControl. Mainly it will be a container for another elements so it needs PersistChildrenAttribute and ParseChildrenAttribute to be set correctly. BackColor and BorderColor properties have been defined in the base class, only radius of circle has to be added. [PersistChildren(true),
ParseChildren(false),
ToolboxData("<{0}:RoundedPanel runat=\"server\"></{0}:RoundedPanel>"),
Designer(typeof(Sy…