protected void grdBroadcasts_OnRowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                //store which row was clicked
                Int32 selectedRow = e.RowIndex;

                //get the selected StudentID using the grid's Data Key collection
                Int32 BroadcastID = Convert.ToInt32(grdBroadcasts.DataKeys[selectedRow].Values["BroadcastID"]);

                //use EF to remove the selected broadcast from the db
                using (wfbEntities2 db = new wfbEntities2())
                {
                    Broadcast b = (from objB in db.Broadcasts
                                   where objB.BroadcastID == BroadcastID
                                   select objB).FirstOrDefault();
                    //do the delete
                    db.Broadcasts.Remove(b);
                    db.SaveChanges();
                }

                //refresh the grid
                getBroadcasts();
            }
            catch (Exception d)
            {
                Response.Redirect("/error.aspx");
            }
        }
        protected void btnBroadcast_Click(object sender, EventArgs e)
        {
            try
            {
                //use EF to connect to SQL Server
                using (wfbEntities2 db = new wfbEntities2())
                {

                    //use the broadcast model to save the new record
                    Broadcast b = new Broadcast();
                    Int32 BroadcastID = 0;

                    //check the querystring for an id so we can determine add / update
                    if (Request.QueryString["BroadcastID"] != null)
                    {
                        //get the id from the url
                        BroadcastID = Convert.ToInt32(Request.QueryString["BroadcastID"]);

                        //get the current broadcast from EF
                        b = (from objB in db.Broadcasts
                             where objB.BroadcastID == BroadcastID
                             select objB).FirstOrDefault();
                    }

                    b.MessageBroadcast = txtMessage.Text;
                    b.Reference_CompanyID = 1;
                    b.SignatureBroadcast = txtName.Text;
                    b.TitleBroadcast = txtTitle.Text;

                    //call add only if we have no broadcast ID
                    if (BroadcastID == 0)
                    {
                        db.Broadcasts.Add(b);
                    }

                    //run the update or insert
                    db.SaveChanges();

                    //redirect to the updated students page
                    Response.Redirect("/admin/broadcasts.aspx");
                }
            }
            catch (Exception d)
            {
                Response.Redirect("/error.aspx");
            }
        }