DataBind

Discussion in 'ASP .Net' started by Calvin Lai, Jan 21, 2004.

  1. Calvin Lai

    Calvin Lai Guest

    Hi all,

    Say I have a DataTable object (oDT) resting on the ViewState object. And I
    have a button called AddButton and a DataGrid, which its datasource is the
    oDT.

    If I want my app behaves so that whenever the user clicked the AddButton,
    internally (server side) will add a row into the oDT and the DataGrid will
    reflect such changes, AND, with that newly added row as editable.

    I have tried many different ways but still no hope. Below is my code
    snipplet.

    AddButton_Click()
    {
    oDT.Rows.Add(oDT.NewRow());
    oDG.Datasource = oDT;
    oDG.DataBind();
    oDG.EditeItemIndex = oDT.Rows.Count;
    ....
    }

    and it doesn't work...please help.

    Calvin
    Calvin Lai, Jan 21, 2004
    #1
    1. Advertising

  2. Calvin Lai

    Alvin Bruney Guest

    I'm providing a link to attach a row to a datagrid. Then you would need to
    set the edit item index to the row depending on where you add it, the index
    may vary
    http://tinyurl.com/ytvrg
    --
    Regards,
    Alvin Bruney [ASP.NET MVP]
    Got tidbits? Get it here...
    http://tinyurl.com/3he3b
    "Calvin Lai" <clai[at]qdata[dot]com> wrote in message
    news:uiJjo%...
    > Hi all,
    >
    > Say I have a DataTable object (oDT) resting on the ViewState object. And I
    > have a button called AddButton and a DataGrid, which its datasource is the
    > oDT.
    >
    > If I want my app behaves so that whenever the user clicked the AddButton,
    > internally (server side) will add a row into the oDT and the DataGrid will
    > reflect such changes, AND, with that newly added row as editable.
    >
    > I have tried many different ways but still no hope. Below is my code
    > snipplet.
    >
    > AddButton_Click()
    > {
    > oDT.Rows.Add(oDT.NewRow());
    > oDG.Datasource = oDT;
    > oDG.DataBind();
    > oDG.EditeItemIndex = oDT.Rows.Count;
    > ...
    > }
    >
    > and it doesn't work...please help.
    >
    > Calvin
    >
    >
    Alvin Bruney, Jan 24, 2004
    #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. Ante Perkovic

    Me.databind() stops button handlers?

    Ante Perkovic, Jun 30, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    909
    Ante Perkovic
    Jun 30, 2003
  2. Admin
    Replies:
    0
    Views:
    666
    Admin
    Jul 8, 2003
  3. Jay

    Databind

    Jay, Jul 25, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    718
    S. Justin Gengo
    Jul 28, 2003
  4. Kimberly Walker

    Dropdownlist adding data after databind

    Kimberly Walker, Oct 23, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    460
    Kimberly Walker
    Oct 23, 2003
  5. Michael
    Replies:
    0
    Views:
    221
    Michael
    Dec 29, 2003
Loading...

Share This Page