By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,854 Members | 1,871 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,854 IT Pros & Developers. It's quick & easy.

Creating or Getting a Dataset from a grid

P: n/a
I have a grid that shows the file list from a folder.
On the postback, how do I get a Dataset from this grid?
Thanks,
Filippo.
Nov 15 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi Filippo,

The grid is intended to work as a view of a data backend ( like a dataset )
it's not intended as a datasource , it's possible to take a grid and build a
data collection with it, basically a collection or records ( you can view
this as a array or a table), you could create a dataset with a table that
contain the same number of columns that cells has a grid's row.

Now this is extremely cumbersome and error prone, if what you have on the
grid is a listing of a folder's file then you should have previously bind
this grid with this data, using somethinig like Directory.GetFiles( )
If it's so then you could keep this array on session and in the postback
just get it back:

string[] FileArray;

if ( !IsPostBack )
{
FileArray = Directory.GetFiles( Request.PhysicalApplicationPath )
Session["FileArray"] = FileArray;

}
else
{
FileArray = string[] Session["FileArray"];
}
Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Filippo Pandiani" <pa********@hotmail.com> wrote in message
news:O8*************@TK2MSFTNGP11.phx.gbl...
I have a grid that shows the file list from a folder.
On the postback, how do I get a Dataset from this grid?
Thanks,
Filippo.

Nov 15 '05 #2

P: n/a
True,
but we also want to use the generic grid to upload XML files,
allow the user to make changes on the grid (Add, Edit, Del)
and then save back the grid values into the XML.

So, I was looking at creating my own XML with 2 for loops (Columns & Rows)

At that point I wonder if I could get a dataset off the grid and save it as
XML.
Filippo.

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi Filippo,

The grid is intended to work as a view of a data backend ( like a dataset ) it's not intended as a datasource , it's possible to take a grid and build a data collection with it, basically a collection or records ( you can view
this as a array or a table), you could create a dataset with a table that
contain the same number of columns that cells has a grid's row.

Now this is extremely cumbersome and error prone, if what you have on the
grid is a listing of a folder's file then you should have previously bind
this grid with this data, using somethinig like Directory.GetFiles( )
If it's so then you could keep this array on session and in the postback
just get it back:

string[] FileArray;

if ( !IsPostBack )
{
FileArray = Directory.GetFiles( Request.PhysicalApplicationPath )
Session["FileArray"] = FileArray;

}
else
{
FileArray = string[] Session["FileArray"];
}
Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Filippo Pandiani" <pa********@hotmail.com> wrote in message
news:O8*************@TK2MSFTNGP11.phx.gbl...
I have a grid that shows the file list from a folder.
On the postback, how do I get a Dataset from this grid?
Thanks,
Filippo.


Nov 15 '05 #3

P: n/a
Hi ,
The datasource of the grid is not important, the issue is that the grid is
mean only as a display of the data, that is kept somewhere else ( dataset,
xml, etc )

Maybe with one example this become clearer.
If the user edit one row, this generate a postback, in the postback you set
the DataGrid.EditItemIndex = e.Item.ItemIndex and then call
DataGrid.DataBind() to rebind the grid.

In the Update command of the grid you should get the edited values, update
the datasource and set the EditItemIndex = -1 and rebind the grid again, as
you can see you rebind the grid anytime that the datasource changed or how
that data is viewed is modified ( as put a row in edit mode ).

Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Filippo Pandiani" <pa********@hotmail.com> wrote in message
news:u9**************@TK2MSFTNGP09.phx.gbl...
True,
but we also want to use the generic grid to upload XML files,
allow the user to make changes on the grid (Add, Edit, Del)
and then save back the grid values into the XML.

So, I was looking at creating my own XML with 2 for loops (Columns & Rows)

At that point I wonder if I could get a dataset off the grid and save it as XML.
Filippo.

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi Filippo,

The grid is intended to work as a view of a data backend ( like a dataset )
it's not intended as a datasource , it's possible to take a grid and build a
data collection with it, basically a collection or records ( you can

view this as a array or a table), you could create a dataset with a table that contain the same number of columns that cells has a grid's row.

Now this is extremely cumbersome and error prone, if what you have on the grid is a listing of a folder's file then you should have previously bind this grid with this data, using somethinig like Directory.GetFiles( )
If it's so then you could keep this array on session and in the postback just get it back:

string[] FileArray;

if ( !IsPostBack )
{
FileArray = Directory.GetFiles( Request.PhysicalApplicationPath )
Session["FileArray"] = FileArray;

}
else
{
FileArray = string[] Session["FileArray"];
}
Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Filippo Pandiani" <pa********@hotmail.com> wrote in message
news:O8*************@TK2MSFTNGP11.phx.gbl...
I have a grid that shows the file list from a folder.
On the postback, how do I get a Dataset from this grid?
Thanks,
Filippo.



Nov 15 '05 #4

P: n/a
Hummm I see.
OK let me give you a better idea of what I am doing.

I have a tree that shows 6 different XML names.
On click of a node I load the XML on a datagrid.

Then I let the user make changes (ADD-EDIT_DEL) and never post back until
the user clicks the SAVE button.

At that point, I get the MyDataGrid updated values and
....and save to XML.

I read somewhere that I could convert my grid back into a DataSet
and then (off course) save the DataSet as XML.

Even if I use the Edit-Add-Del events, I still don't understand how I can
update the datasource. What does the datasource, at that time looks like?

Is it a DataSet, or is it an XML in memory... ?

Hizzzzz !!!

<hehe>

Filippo.

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:uz**************@TK2MSFTNGP11.phx.gbl...
Hi ,
The datasource of the grid is not important, the issue is that the grid is mean only as a display of the data, that is kept somewhere else ( dataset,
xml, etc )

Maybe with one example this become clearer.
If the user edit one row, this generate a postback, in the postback you set the DataGrid.EditItemIndex = e.Item.ItemIndex and then call
DataGrid.DataBind() to rebind the grid.

In the Update command of the grid you should get the edited values, update
the datasource and set the EditItemIndex = -1 and rebind the grid again, as you can see you rebind the grid anytime that the datasource changed or how
that data is viewed is modified ( as put a row in edit mode ).

Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Filippo Pandiani" <pa********@hotmail.com> wrote in message
news:u9**************@TK2MSFTNGP09.phx.gbl...
True,
but we also want to use the generic grid to upload XML files,
allow the user to make changes on the grid (Add, Edit, Del)
and then save back the grid values into the XML.

So, I was looking at creating my own XML with 2 for loops (Columns & Rows)

At that point I wonder if I could get a dataset off the grid and save it

as
XML.
Filippo.

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>

wrote
in message news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi Filippo,

The grid is intended to work as a view of a data backend ( like a

dataset )
it's not intended as a datasource , it's possible to take a grid and

build
a
data collection with it, basically a collection or records ( you can

view this as a array or a table), you could create a dataset with a table that contain the same number of columns that cells has a grid's row.

Now this is extremely cumbersome and error prone, if what you have on the grid is a listing of a folder's file then you should have previously bind this grid with this data, using somethinig like Directory.GetFiles( )
If it's so then you could keep this array on session and in the postback just get it back:

string[] FileArray;

if ( !IsPostBack )
{
FileArray = Directory.GetFiles( Request.PhysicalApplicationPath )
Session["FileArray"] = FileArray;

}
else
{
FileArray = string[] Session["FileArray"];
}
Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Filippo Pandiani" <pa********@hotmail.com> wrote in message
news:O8*************@TK2MSFTNGP11.phx.gbl...
> I have a grid that shows the file list from a folder.
> On the postback, how do I get a Dataset from this grid?
>
>
> Thanks,
> Filippo.
>
>



Nov 15 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.