F
Filippo Pandiani
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.
On the postback, how do I get a Dataset from this grid?
Thanks,
Filippo.
Ignacio Machin ( .NET/ C# MVP ) said: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 said: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.
Filippo Pandiani said: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:%[email protected]...buildHi 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 anda
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 said: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.
Ignacio Machin ( .NET/ C# MVP ) said: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 said: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:%[email protected]...buildHi 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 anda
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
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.