Gets an old text value in text box of edit column of datagrid?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sarangrao
    New Member
    • Apr 2009
    • 21

    #1

    Gets an old text value in text box of edit column of datagrid?

    I created TextBox at runtime.

    TextBox t1=(TextBox)e.I tem.Cells[no. of the cell].Controls["txtMyTextB ox"];

    Iam using above code and using it as below:

    mycommand.Param eters["@m_price"].Value=Convert. ToDecimal(txtMy textBox.Text)

    it is showing me error that txtMyTextBox not found.


    Also, TextBox t1=(TextBox)e.I tem.Cells[no. of the cell].FindControl("t xtMyTextBox");

    But in html code,how will I insert txtMyText:

    <asp:BoundColum n DataField="pric e" HeaderText="Pri ce"></asp:BoundColumn >
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    TextBox t1=(TextBox)e.I tem.Cells[no. of the cell].Controls["txtMyTextBox"];

    mycommand.Param eters["@m_price"].Value=Convert. ToDecimal(txtMytextBox.Text)

    it is showing me error that txtMyTextBox not found.
    I would look very carefully at the cases of your control names.
    Even in this example you are not consistent. It probably can't find the control because the one with the casing you specified doesn't exist.

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      When are you creating your TextBox?
      Is your TextBox available at that time (are you in edit mode? is the textbox available then?)

      -Frinny

      Comment

      • sarangrao
        New Member
        • Apr 2009
        • 21

        #4
        There is no point in creating text box in edit mode.Because after clicking on edit,when update text comes i write the value in the textbox and then click update.There iam getting old value in the textbox.not a new value.Also in page_load event,I cannot call Datagrideventar gs e

        Comment

        • Frinavale
          Recognized Expert Expert
          • Oct 2006
          • 9749

          #5
          Are you doing a DataBind on the GridView in the Page Load event?

          Comment

          Working...