but now facing problem in row updating.
cant able to assign values which will be updated.
i using layers (BusinessEntity,Logic nd dataaccess)
so here is my code
binding data in gridview
private void BindGrid()
{
UserInfoBE objUserBE = new UserInfoBE();
objUserBE.EmailId = lblID.Text;
UserInfoBL objUserBL = new UserInfoBL();
GridView1.DataSource = objUserBL.SelectAllUserInfo(objUserBE);
GridView1.DataBind();
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
UserInfoBE objUserBE = new UserInfoBE();
objUserBE.EmailId =((TextBox)GridView1.Rows[e.RowIndex].Cells[2]).Text;
objUserBE.FirstName = ((TextBox)GridView1.Rows[e.RowIndex].Cells[2]).Text;
objUserBE.LastName = ((TextBox)GridView1.Rows[e.RowIndex].Cells[2]).Text;
objUserBE.Mobile = ((TextBox)GridView1.Rows[e.RowIndex].Cells[2]).Text;
objUserBE.Address =((TextBox)GridView1.Rows[e.RowIndex].Cells[2]).Text;
UserInfoBL objUserBL = new UserInfoBL();
if (objUserBL.InsertUpdateUserInfo(objUserBE) > 0)
{
GridView1.EditIndex = -1;
BindGrid();
lblmsg.Text = "Update";
}
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
BindGrid();
}
i know where i m making mistake,. i m using itemtemplate field where i set textboxes. nd labels.
here is the structure
onrowediting="GridView1_RowEditing" onrowupdating="GridView1_RowUpdating"
AutoGenerateEditButton="True">
how to give values to business entity layer.
i cant send code file please tell me possible changes so tht i can i assign those values field to BE.
thanks
Dipa AhujaPosted Apr 21, 2010, 9:46 AM
Rashid KhanPosted Apr 21, 2010, 2:48 AM
thanks for reply.
as per your suggestion i used
but for showing i have to use
but the problem still the same.
i fetch the values form database. and showing in gridview then i want if user want to update their record just click on edit button and change the data.
but while debugging i found the values were not changes. i changed the values in textbox and click update but its not change, same old values are passing.
may i am making mistake to assigning. could you please tell me how to set values.,
GridView Design
onrowupdating="GridView1_RowUpdating"
onrowcancelingedit="GridView1_RowCancelingEdit">
C-SharpCode
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
UserInfoBE objUserBE = new UserInfoBE();
//LoginBE objLoginBE = new LoginBE();
//objLoginBE.EmailId = GridView1.DataKeys[GridView1.SelectedIndex].Value.ToString();
objUserBE.EmailId = ((TextBox)GridView1.Rows[0].FindControl("txtEmail")).Text;
objUserBE.FirstName = ((TextBox)GridView1.Rows[e.RowIndex].Cells[1].FindControl("txtFirstName")).Text;
objUserBE.LastName = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtLastName")).Text;
objUserBE.Mobile = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtMobile")).Text;
objUserBE.Address = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtAddress")).Text;
//LoginBL objLoginBL = new LoginBL();
UserInfoBL objUserBL = new UserInfoBL();
//if(objLoginBL.InsertUpdateLogin(objLoginBE)!="0")
//{
if (objUserBL.InsertUpdateUserInfo(objUserBE) > 0)
{
GridView1.EditIndex = -1;
BindGrid();
lblmsg.Text = "Update";
}
i try all my efforts. i can ask to my Sir. but its my project. so have to done own my own nd with the help of c-sharpcorner.com's expert someone like u
thanks for u kind help
Take care
Dipa AhujaPosted Apr 20, 2010, 12:03 PM