protected void GvRowCommand(object sender, GridViewCommandEventArgs e)
        {
            string editpage = "~/ControlRoom/Modules/Setup/BookListBooksAddEdit.aspx";

            if (e.CommandName.ToLower() == "addrecord")
            {
                Session["BLL"] = string.Empty; Response.Redirect(editpage);
            }

            if (e.CommandName.ToLower() == "deleterecord")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                try
                {
                    var obj = new BookListBooks();
                    if (obj.IsValid(BusinessRulesValidationMode.DELETE))
                    {
                        BookListBooks.FetchObject(key).Delete();

                        LoadData();
                        var masterPage = (IControlRoomMaster)Master;
                        if (masterPage != null)
                        {
                            masterPage.PageMessage = SRPResources.DeleteOK;
                        }
                    }
                    else
                    {
                        var    masterPage = (IControlRoomMaster)Master;
                        string message    = String.Format(SRPResources.ApplicationError1, "<ul>");
                        foreach (BusinessRulesValidationMessage m in obj.ErrorCodes)
                        {
                            message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage);
                        }
                        message = string.Format("{0}</ul>", message);
                        if (masterPage != null)
                        {
                            masterPage.PageError = message;
                        }
                    }
                }
                catch (Exception ex)
                {
                    var masterPage = (IControlRoomMaster)Master;
                    if (masterPage != null)
                    {
                        masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                    }
                }
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                var obj = new BookListBooks();

                //obj.BLID = FormatHelper.SafeToInt(((DropDownList) ((DetailsView) sender).FindControl("BLID")).SelectedValue);
                obj.BLID   = FormatHelper.SafeToInt(lblPK.Text);
                obj.Author = Author.Text.Trim();
                obj.Title  = BookTitle.Text.Trim();
                obj.ISBN   = ISBN.Text.Trim();
                obj.URL    = URL.Text.Trim();

                obj.AddedDate   = DateTime.Now;
                obj.AddedUser   = ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username; //"N/A";  // Get from session
                obj.LastModDate = obj.AddedDate;
                obj.LastModUser = obj.AddedUser;

                if (obj.IsValid(BusinessRulesValidationMode.INSERT))
                {
                    obj.Insert();
                    Author.Text = BookTitle.Text = ISBN.Text = URL.Text = string.Empty;

                    odsData.DataBind();
                    gv.DataBind();

                    var masterPage = (IControlRoomMaster)Master;
                    masterPage.PageMessage = SRPResources.AddedOK;
                }
                else
                {
                    var    masterPage = (IControlRoomMaster)Master;
                    string message    = String.Format(SRPResources.ApplicationError1, "<ul>");
                    foreach (BusinessRulesValidationMessage m in obj.ErrorCodes)
                    {
                        message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage);
                    }
                    message = string.Format("{0}</ul>", message);
                    masterPage.PageError = message;
                }
            }
            catch (Exception ex)
            {
                var masterPage = (IControlRoomMaster)Master;
                masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
            }
        }