Example #1
0
    protected void gv_books_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        string     bid     = (gv_books.Rows[e.RowIndex].FindControl("lbl_bid") as Label).Text;
        string     bname   = (gv_books.Rows[e.RowIndex].FindControl("txt_bname") as TextBox).Text;
        string     bauthor = (gv_books.Rows[e.RowIndex].FindControl("txt_bAuthor") as TextBox).Text;
        string     btitle  = (gv_books.Rows[e.RowIndex].FindControl("txt_bTitle") as TextBox).Text;
        string     bprice  = (gv_books.Rows[e.RowIndex].FindControl("txt_bPrice") as TextBox).Text;
        string     bpages  = (gv_books.Rows[e.RowIndex].FindControl("txt_bNoofPages") as TextBox).Text;
        FileUpload bimage  = (gv_books.Rows[e.RowIndex].FindControl("txt_bimg") as FileUpload);
        string     address = "~/Images/" + Guid.NewGuid() + ".jpg";

        bimage.SaveAs(Server.MapPath(address));
        LibraryDAL dal = new LibraryDAL();

        dal.Update(Convert.ToInt32(bid), bname, bauthor, btitle, Convert.ToInt32(bprice), Convert.ToInt32(bpages), address);
        gv_books.EditIndex = -1;

        List <BookModel> list = dal.Search(txt_search.Text);

        gv_books.DataSource = list;
        gv_books.DataBind();
        lbl_msg.Text = "Updated Successfully...";
    }