ListView with internal records

Discussion in 'ASP .Net' started by Jakob Lithner, Feb 15, 2010.

  1. I would like to have a webpage with a list of items for the user to send for
    processing.

    When the user enters the page I usually would like to enter a couple of
    default items. Then it should be possible to edit, delete and insert items to
    the list.
    After all editing is ready, the list can be sent for processing.

    I found out the ListView control looked like a great candidate. I added a
    ListView and configured a corresponding ObjectDataSource. The
    ObjectDataSource calls a handler class that creates the default entities. It
    works fine so far.

    But when I want to configure the Update, Delete and Insert commands I am
    stuck. All examples are related to items being stored in database between
    each call. But I don't want to store anything in database until the final
    list is submitted.

    Is this possible? Can I have a grid with records only "stored internally in
    viewstate" and still allow editing?
    Jakob Lithner, Feb 15, 2010
    #1
    1. Advertising

  2. Jakob Lithner

    Steven Cheng Guest

    Hi,

    Regarding on your description, have you considered using a in-memory
    dataset/datatable to hold the items/records you want to
    manage(update/delete/insert) through the ListView(or other databound
    control)? Thus, you can store the datatable/dataset either in page's
    viewstate or SessionState(store in viewstate will cause the page's response
    size increase much.

    #Insert/Update/Delete operations on dataset
    http://forums.asp.net/p/1156913/2234796.aspx#2234796

    #How to bind GridView and DropDownList controls using DataTable object
    http://www.devasp.net/net/articles/display/278.html

    #ASP.Net Bind GridView to DataTable
    http://programming.top54u.com/post/ASP-Net-Bind-GridView-to-DataTable.aspx

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    .


    --------------------
    >From: =?Utf-8?B?SmFrb2IgTGl0aG5lcg==?= <>
    >Subject: ListView with internal records
    >Date: Mon, 15 Feb 2010 05:33:01 -0800


    >
    >I would like to have a webpage with a list of items for the user to send

    for
    >processing.
    >
    >When the user enters the page I usually would like to enter a couple of
    >default items. Then it should be possible to edit, delete and insert items

    to
    >the list.
    >After all editing is ready, the list can be sent for processing.
    >
    >I found out the ListView control looked like a great candidate. I added a
    >ListView and configured a corresponding ObjectDataSource. The
    >ObjectDataSource calls a handler class that creates the default entities.

    It
    >works fine so far.
    >
    >But when I want to configure the Update, Delete and Insert commands I am
    >stuck. All examples are related to items being stored in database between
    >each call. But I don't want to store anything in database until the final
    >list is submitted.
    >
    >Is this possible? Can I have a grid with records only "stored internally

    in
    >viewstate" and still allow editing?
    >
    Steven Cheng, Feb 16, 2010
    #2
    1. Advertising

  3. On Feb 15, 2:33 pm, Jakob Lithner <> wrote:
    > I would like to have a webpage with a list of items for the user to send for
    > processing.
    >
    > When the user enters the page I usually would like to enter a couple of
    > default items. Then it should be possible to edit, delete and insert items to
    > the list.
    > After all editing is ready, the list can be sent for processing.
    >
    > I found out the ListView control looked like a great candidate. I added a
    > ListView and configured a corresponding ObjectDataSource. The
    > ObjectDataSource calls a handler class that creates the default entities. It
    > works fine so far.
    >
    > But when I want to configure the Update, Delete and Insert commands I am
    > stuck. All examples are related to items being stored in database between
    > each call. But I don't want to store anything in database until the final
    > list is submitted.
    >
    > Is this possible? Can I have a grid with records only "stored internally in
    > viewstate" and still allow editing?


    Hi Jakob,

    I think you can easily do this. On initial load, check viewstate and
    create a new dataset if there is no data and bind the listview to the
    dataset. If viewstate has already some data, retrieve the dataset from
    there

    if (ViewState["dSet"] != null) {

    System.IO.StringReader sr = new System.IO.StringReader((string)
    (ViewState["dSet"]));
    dSet.ReadXml(sr);

    } else {

    System.IO.StringWriter sw = new System.IO.StringWriter();

    // Write the DataSet to the ViewState property.
    dSet.WriteXml(sw);
    ViewState["dSet"] = sw.ToString();

    }

    http://msdn.microsoft.com/en-us/library/aa287542.aspx
    http://msdn.microsoft.com/en-us/library/aa287539.aspx

    After that you should be able to work with listview as with a
    database.

    Hope this helps
    Alexey Smirnov, Feb 16, 2010
    #3
    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. Luke Airig
    Replies:
    0
    Views:
    774
    Luke Airig
    Dec 31, 2003
  2. David C

    ListView insert - no current records

    David C, Nov 12, 2009, in forum: ASP .Net
    Replies:
    0
    Views:
    546
    David C
    Nov 12, 2009
  3. .
    Replies:
    0
    Views:
    704
  4. Dan

    Delete records or update records

    Dan, May 10, 2004, in forum: ASP General
    Replies:
    1
    Views:
    454
    Ray at
    May 10, 2004
  5. Replies:
    3
    Views:
    644
    Anthony Jones
    Nov 2, 2006
Loading...

Share This Page