none
Design guideline needed for disconnected application RRS feed

  • General discussion

  • Hello,

    Visitors to my website will need to be able to populate data which will be stored in memory and never writtent to any permament storage. Say for example I ask them to input list of filenames they plan to upload and for each file I ask them to input custom name once file is uploaded. I'd like to minimize any development time so I want to use GridView and DataSet.
    My question is what kind of datasource I should be using for GridView to able to design UI in Visual Studio? I can create model via DataSet designer but have trouble bringing it to front-end. Secondly will it be possible to use Entity Framework instead?
    All this bearing in mind there will be no mapping for EntityFramework or TableAdapters for DataSet since none of the data will be ever stored anywhere permament (only in memory).

    Thanks,
    G
    Tuesday, August 25, 2009 8:25 PM

All replies

  • Hello Lorry,

     

    Datasource of GridView can be various of things, like DataSet, DataTable, In-memory collections, arrays and so on. So, using what kind of DataSource depends on what data you want to bind. If the data you want to bind is from Database, you can use Adapter to fill it in DataSet and use DataSet as DataSource.

    But from your description, I am not very clear what data you want to bind to your GridView? Do you mean, you want to show the end user uploaded file, filename in the DataGridView? And you do not want to store the file in your server, right? If that is the case, you can create a collection of a customized type that consist of the information you want to display. Then you can bind that in-memory collection to the GridView.

    Some codes,
    --------------------------------------------------------------------
    public class FileInfo
    {
        public string FileName
        {
            get;
            set;
        }

        public string Uploader
        {
            get;
            set;
        }
        public MemoryStream File
        {
            get;
            set;
        }

        public FileInfo(String n, String u, MemoryStream f)
        {
            FileName = n;
            Uploader = u;
            File = f;
        }
    }
    --------------------------------------------------------------------
        System.Collections.ArrayList arraylist = new System.Collections.ArrayList();

        protected void Page_Load(object sender, EventArgs e)
        {
            arraylist.Add(new FileInfo("file1","colbert", new MemoryStream()));
            arraylist.Add(new FileInfo("file2","colbert", new MemoryStream()));
            arraylist.Add(new FileInfo("file3","colbert", new MemoryStream()));

            this.GridView1.DataSource = arraylist;
            GridView1.DataBind();
        }

        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.Header)
            {
                e.Row.Cells[0].Text = "FileName";
                e.Row.Cells[1].Text = "Uploader";
            }
        }
    --------------------------------------------------------------------


    If we are using in-memory datasource, I do not think Entity Framework is appropriate to be used here. Hope this helps!

    Have a nice day! :-) 


    Ji Zhou

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Wednesday, August 26, 2009 8:16 AM
    Moderator