Data grid updation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • smithak82
    New Member
    • Sep 2008
    • 12

    Data grid updation

    In my code i am not able to get the new value from thre textbox which got created when we click the edit button. IT is taking the value which is retried from the database. please help...

    Code:
    protected void qltyGrid_EditCommand(object source,System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            qltyGrid.EditItemIndex = e.Item.ItemIndex;
            BindData();
        }
    protected void qltyGrid_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            string cName = ((TextBox)e.Item.Cells[1].Controls[0]).Text;
    
            ShowMsg(cName);
            SqlCommand com = new SqlCommand("update QualityMasters set QltyName='" + cName  + "' where QltyId='" + 2 + "';", con);
            con.Open();
            com.ExecuteNonQuery();
            con.Close();
            qltyGrid.EditItemIndex = -1;
            BindData();
        }
    Last edited by Curtis Rutland; Sep 25 '08, 01:34 PM. Reason: Added Code Tags - Please surround your code with [CODE] and [/CODE]
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    In your Page Load event....are you performing a DataBind on your GridView?

    When you do this all the data that has been entered during editing is deleted...becau se the data source has been switched. This could be the reason why you cannot retrieve the text from the edit text box.

    -Frinny

    Comment

    • smithak82
      New Member
      • Sep 2008
      • 12

      #3
      yes it is true. that was the problem. from yesterday i am breaking my head.
      thanks a lot.

      Comment

      Working...