예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //we have to add this dynamic control on every load
            Button b = new Button();

            dyncontrol.Controls.Add(b);
            b.Text        = "Back to Home";
            b.PostBackUrl = "/";
            if (!this.IsPostBack)
            {
                USStates s = new USStates();
                Dictionary <string, string> L;
                Literal1.Mode       = LiteralMode.PassThrough;
                Literal1.Text       = s.AsHtmlTable();
                L                   = s.AsDictionary();
                Ddl1.DataSource     = L;
                Ddl1.DataTextField  = "Value";
                Ddl1.DataValueField = "Key";
                Ddl1.DataBind();
                SState.Text      = "No State Selected";
                Gv1.AllowSorting = true;
                Gv1.DataSource   = s.AsDataTable();
                Gv1.DataBind();
            }
            else
            {
            }
        }
예제 #2
0
        protected void GridViewSortEventHandler(object sender, GridViewSortEventArgs e)
        {
            USStates s = new USStates();
            DataView v = new DataView(s.AsDataTable());

            v.Sort         = e.SortExpression + " ASC";
            Gv1.DataSource = v;
            Gv1.DataBind();
        }