Edit/Update/Cancel Problem

Discussion in 'ASP .Net Datagrid Control' started by mschmidt18@gmail.com, Jul 10, 2006.

  1. Guest

    Hello,

    I have a datagrid (.net 1.1) with an edit/update/cancel column. I am
    having trouble capturing the data when the update event fires. It is
    getting whatever was in the textbox before it was changed.

    Here is some of my code:

    c#

    System.Web.UI.WebControls.TextBox p_productDesc = new
    System.Web.UI.WebControls.TextBox();
    p_productDesc = (System.Web.UI.WebControls.TextBox)
    e.Item.Cells[3].Controls[0];
    .....
    sp[0] = new SqlParameter("@productId",e.Item.ItemIndex);
    sp[1] = new SqlParameter("@productDesc",p_productDesc.Text.ToString());


    I also need help with the ItemIndex. I am using paging and it doesnt
    seem to be working right, I need the true ID of the row.

    If you need to see more code, just ask! Thanks!
     
    , Jul 10, 2006
    #1
    1. Advertising

  2. Scott M. Guest

    You need to find the row index for the underlying DataTable that the grid is
    working off of, not the row index from the grid.

    You'll need to do someting like this:

    [VB.NET]

    Dim dataSetRow As DataRow = dataSet.Tables(0).Select("PrimaryKey =" &
    CType(e.Item.FindControl("theTextboxName",Textbox).Text(0)


    Now, dataSetRow represents the row in your DataSet that contains the data
    being edited.
    So, you can just look at whatever field in that row you want.

    <> wrote in message
    news:...
    > Hello,
    >
    > I have a datagrid (.net 1.1) with an edit/update/cancel column. I am
    > having trouble capturing the data when the update event fires. It is
    > getting whatever was in the textbox before it was changed.
    >
    > Here is some of my code:
    >
    > c#
    >
    > System.Web.UI.WebControls.TextBox p_productDesc = new
    > System.Web.UI.WebControls.TextBox();
    > p_productDesc = (System.Web.UI.WebControls.TextBox)
    > e.Item.Cells[3].Controls[0];
    > ....
    > sp[0] = new SqlParameter("@productId",e.Item.ItemIndex);
    > sp[1] = new SqlParameter("@productDesc",p_productDesc.Text.ToString());
    >
    >
    > I also need help with the ItemIndex. I am using paging and it doesnt
    > seem to be working right, I need the true ID of the row.
    >
    > If you need to see more code, just ask! Thanks!
    >
     
    Scott M., Jul 10, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U3RldmUgS2FsbGFs?=

    CssClass on DataGrid Edit, Update & Cancel buttons

    =?Utf-8?B?U3RldmUgS2FsbGFs?=, Jul 6, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    743
    =?Utf-8?B?U3RldmUgS2FsbGFs?=
    Jul 6, 2004
  2. =?Utf-8?B?SmFjcXVlcyBMZWNsZXJj?=

    RE: Setting CssClass on Edit, Update & Cancel buttons

    =?Utf-8?B?SmFjcXVlcyBMZWNsZXJj?=, Jul 6, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    516
    =?Utf-8?B?SmFjcXVlcyBMZWNsZXJj?=
    Jul 6, 2004
  3. Craig G
    Replies:
    2
    Views:
    689
    Patrick Olurotimi Ige
    Dec 14, 2004
  4. =?Utf-8?B?cG11ZA==?=

    CANT see EDIT UPDATE CANCEL Buttons for DATAGRID

    =?Utf-8?B?cG11ZA==?=, Dec 28, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    2,420
    =?Utf-8?B?cG11ZA==?=
    Dec 28, 2004
  5. Replies:
    1
    Views:
    169
    Elton Wang
    Apr 7, 2005
Loading...

Share This Page