示例#1
0
    protected void MyUrlsGridView_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        var commands = new[] { "start", "stop", "remove" };

        if (commands.Contains(e.CommandName))
        {
            var index = e.GetSelectedRowIndex() % MyUrlsGridView.PageSize;
            var row   = MyUrlsGridView.Rows[index];
            var urlId = (row.Cells[0].Text.Trim());
            var url   = new UserUrl(Convert.ToInt32(urlId));

            switch (e.CommandName)
            {
            case "start":
                if (url.Status == AdvertStatus.Paused)
                {
                    url.Activate();
                }
                break;

            case "stop":
                if (url.Status == AdvertStatus.Active)
                {
                    url.Pause();
                }
                break;

            case "remove":
                url.Delete();
                break;
            }

            MyUrlsGridView.DataBind();
        }
    }
示例#2
0
 protected void MyUrlsView_Activate(object sender, EventArgs e)
 {
     MyUrlsGridView.DataBind();
 }