protected void TransGridView_DataBound(object sender, EventArgs e)
 {
     PageList.Items.Clear();
     for (int i = 0; i < TransGridView.PageCount; i++)
     {
         Telerik.Web.UI.DropDownListItem pageListItem =
             new Telerik.Web.UI.DropDownListItem(String.Concat("Page ", i + 1, " of ", TransGridView.PageCount), i.ToString());
         PageList.Items.Add(pageListItem);
         if (i == TransGridView.CurrentPageIndex)
         {
             pageListItem.Selected = true;
         }
     }
 }
示例#2
0
        protected void rGridPlayer_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            try
            {
                //if (e.Item is GridEditFormInsertItem || e.Item is GridDataInsertItem)

                if (e.Item is GridDataItem)
                {
                    GridDataItem dataItem = e.Item as GridDataItem;

                    if (!Roles.IsUserInRole(Page.User.Identity.Name, "CSBA_Admin"))
                    {
                        ImageButton EditButton = (ImageButton)dataItem["EditCommandColumn"].Controls[0];
                        EditButton.Visible = false;
                        ImageButton deleteButton = (ImageButton)dataItem["Delete"].Controls[0];
                        deleteButton.Visible = false;
                    }
                }

                if (e.Item is GridEditFormInsertItem)
                {
                    GridEditFormInsertItem dataItem = e.Item as GridEditFormInsertItem;

                    RadDropDownList rDDPrimPos = (RadDropDownList)dataItem.FindControl("rDDPrimPos");
                    rDDPrimPos.DataSource     = PosBLL.ListPositions();
                    rDDPrimPos.DataValueField = "PositionID";
                    rDDPrimPos.DataTextField  = "PositionNameLong";
                    rDDPrimPos.DataBind();

                    RadDropDownList rDDSecPos = (RadDropDownList)dataItem.FindControl("rDDSecPos");
                    rDDSecPos.DataSource     = PosBLL.ListPositions();
                    rDDSecPos.DataValueField = "PositionID";
                    rDDSecPos.DataTextField  = "PositionNameLong";
                    rDDSecPos.DataBind();
                }
                else if (e.Item is GridEditableItem && e.Item.IsInEditMode)
                {
                    //GridDataItem dataItem = e.Item as GridDataItem;

                    GridEditFormItem dataItem = e.Item as GridEditFormItem;

                    RadDropDownList rDDPrimPos = (RadDropDownList)dataItem.FindControl("rDDPrimPos");
                    rDDPrimPos.DataSource     = PosBLL.ListPositions();
                    rDDPrimPos.DataValueField = "PositionID";
                    rDDPrimPos.DataTextField  = "PositionNameLong";
                    rDDPrimPos.DataBind();
                    var DDLIP = new Telerik.Web.UI.DropDownListItem("-- Select Position --", "0");
                    rDDPrimPos.Items.Insert(0, DDLIP);
                    if (DataBinder.Eval(dataItem.DataItem, "PrimaryPositionID") != null)
                    {
                        rDDPrimPos.SelectedValue = DataBinder.Eval(dataItem.DataItem, "PrimaryPositionID").ToString();
                    }

                    RadDropDownList rDDSecPos = (RadDropDownList)dataItem.FindControl("rDDSecPos");
                    rDDSecPos.DataSource     = PosBLL.ListPositions();
                    rDDSecPos.DataValueField = "PositionID";
                    rDDSecPos.DataTextField  = "PositionNameLong";
                    rDDSecPos.DataBind();
                    var DDLIS = new Telerik.Web.UI.DropDownListItem("-- Select Position --", "0");
                    rDDSecPos.Items.Insert(0, DDLIS);

                    if (DataBinder.Eval(dataItem.DataItem, "SecondaryPostiionID") != null)
                    {
                        rDDSecPos.SelectedValue = DataBinder.Eval(dataItem.DataItem, "SecondaryPostiionID").ToString();
                    }

                    //Image imgPlayer = (Image)e.Item.FindControl("imgPlayer");


                    //byte[] buffer = null;


                    //buffer = (byte[])dataItem.DataItem["PlayerImage"];
                    //MemoryStream memStream = new MemoryStream(buffer);
                    //MemoryStream memStream1 = new MemoryStream();
                    //System.Drawing.Bitmap.FromStream(memStream).Save(memStream1, System.Drawing.Imaging.ImageFormat.Png);
                    //imgPlayer.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(memStream1.ToArray());


                    //byte[] bytes = (dataItem.DataItem["PlayerImage"] as (byte[]));

                    //string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);

                    //Image1.ImageUrl = "data:image/png;base64," + base64String;



                    //RadImageEditor rImage = (RadImageEditor)e.Item.FindControl("RadImageEditor1");
                    //if (rImage != null)
                    //{
                    //    //rImage.ResetChanges();
                    //}
                }
                else if (e.Item is GridItem)
                {
                }
            }
            catch (Exception ex)
            {
                StackTrace st        = new StackTrace();
                StackFrame sf        = st.GetFrame(0);
                string     errMethod = sf.GetMethod().Name.ToString();                                           // Get the current method name
                string     errMsg    = "600";                                                                    // Gotta pass something, we're retro-fitting an existing method
                Session["LastException"] = ex;                                                                   // Throw the exception in the session variable, will be used in error page
                string url = string.Format(ConfigurationManager.AppSettings["ErrorPageURL"], errMethod, errMsg); //Set the URL
                Response.Redirect(url);                                                                          // Go to the error page.
            }
        }