DataGrid, DataList, or something else?

  • Thread starter Thread starter Mo
  • Start date Start date
M

Mo

Hi,

I have a page that keeps track of shipping information. I have everything
laid out in a small table for one destination. Inside the table I have some
server controls (dropdowns labels, linkbuttons, etc.) relevent to one
destination. I would like to add multiple shipping destinations (ie
additional tables) based on user selection. Similarly, I would also like to
have the option of deleting a shipping destination. So in the end, if a
user has specified 3 different shipping destinations complete with all
selections, I would like to insert each destination into the db in
succession. I already have the stored procedure ready to input one
destination. I'm guesssing I have to run a loop (length # of desinations)
and repeatedly call the stored procedure.

I was thinking of using a DataGrid or DataList but I'm not too clear as to
what would work as I do not have anything databound in my table. Any help
on this would be greatly appreciated. Thanks.
 
Your post went unanswered. Have you resolved this issue? If you still need
help, please post the original question with your request.
 
Hi Alvin,

I still haven't resolved this issue. So here is my problem again:

I have a page that I want to keep track of shipping information. The
page should allow the user to add multiple destinations. Each
destination has certain server controls (dropdowns, textboxes,
linkbuttons,etc.) that can be set for a destination.

I have everything laid out in a small table for one destination. Inside
the table I have some server controls (dropdowns labels, linkbuttons,
etc.) relevent to one destination. I would like to add or delete
shipping destinations (ie additional tables) based on user selection.
Furthermore, within a destination, I have a sub table which is to keep
track of order details. This sub table has server controls for various
selections. I would like to be able to add or delete rows (order
details within a destination).

So in the end, if a user has specified 3 different shipping destinations
complete with all selections (ie 1st destination has 2 order details,
2nd destination has 3 order details, and last destination as 1 order
detail), I would like to insert each destination into the db in
succession. I already have the stored procedure ready to input one
destination. I'm guesssing I have to run a loop (of length #
desinations)
and repeatedly call the stored procedure.

I was thinking of using a DataGrid or DataList but I'm not too clear as
to how to make it work as I do not have anything databound in my table.
Someone suggested that I use custom IEnumerable collection object bound
to a datalist. I'm not too sure about the custom collection so I am
currently reading up on it. Any help on how to get this working would
be greatly appreciated.

Thank you kindly.
 
a datagrid or a data list is a good idea. it doesn't have to be bound to a
table. you can collect the data you need to display and build a dataset
manually with the pending orders then display it to the datagrid for
confirmation or editing. Once you are satisfied with the results, you can
push the dataset back to the database. The advantage of using a grid or list
is that the list can grow and expand as needed where as you would have to
keep adding or subtracting controls based on demand.
 
Hi Alvin,

I still haven't resolved this issue. So here is my problem again:

I have a page that I want to keep track of shipping information. The
page should allow the user to add multiple destinations. Each
destination has certain server controls (dropdowns, textboxes,
linkbuttons,etc.) that can be set for a destination.

I have everything laid out in a small table for one destination. Inside
the table I have some server controls (dropdowns labels, linkbuttons,
etc.) relevent to one destination. I would like to add or delete
shipping destinations (ie additional tables) based on user selection.
Furthermore, within a destination, I have a sub table which is to keep
track of order details. This sub table has server controls for various
selections. I would like to be able to add or delete rows (order
details within a destination).

So in the end, if a user has specified 3 different shipping destinations
complete with all selections (ie 1st destination has 2 order details,
2nd destination has 3 order details, and last destination as 1 order
detail), I would like to insert each destination into the db in
succession. I already have the stored procedure ready to input one
destination. I'm guesssing I have to run a loop (of length #
desinations)
and repeatedly call the stored procedure.

I was thinking of using a DataGrid or DataList but I'm not too clear as
to how to make it work as I do not have anything databound in my table.
Someone suggested that I use custom IEnumerable collection object bound
to a datalist. I'm not too sure about the custom collection so I am
currently reading up on it. Any help on how to get this working would
be greatly appreciated.

Thank you kindly.
 
Hi Sorry about my last post, I think I refreshed the submission page
again and it posted my earlier post again.

I understand now the advantages of using a datagrid / datalist for add /
deleting rows. When you said to collect
the data and build a dataset manually, I was a bit unsure as to a couple
of things. Is my order details portion, a datagrid within my
destinations datalist? I don't have any information to display, I just
want the user to select the details, so I'm not sure about editing.

Thanks
 
Assuming your table has an add button for example, you would allow the user
to make their normal selection from the webcontrols then press the add
buton. The add button would retrieve a cached dataset (empty at first) and
add these new selections as a row in the dataset. Then you would bind the
dataset (now containing items) to the datagrid. Here is a rough example of
what i mean.

//assume user pressed add and their are 4 controls in the table build a
dataset with the new information.

[snip] add button routine

DataSet ds = ViewState["DATA"] as DataSet;

//empty if this is first pass
if(ds == null)
{
//first build a new dataset
DataSet dsTemp = new DataSet();
DataTable Tables = new DataTable();
dsTemp.Tables.Add(Tables);

dsTemp.Tables[0].Columns.Add( "Shipping", System.Type.GetType(
"System.String" ) );
dsTemp.Tables[0].Columns.Add( "Receiving", System.Type.GetType(
"System.String" ) );
dsTemp.Tables[0].Columns.Add( "Order Number", System.Type.GetType(
"System.String" ) );
dsTemp.Tables[0].Columns.Add( "Cust Name", System.Type.GetType(
"System.String" ) );
}

DataRow myRow = dsTemp.Tables[0].NewRow();
//shipping
myRow[0]= "value from shipping dropdown";
//receiving
myRow[1]= "value from receiving dropdown";
//order number
myRow[2]= "value from order number dropdown";
//cust name
myRow[3]= "value from cust name dropdown";

//display to screen
dsTemp.Tables[0].Rows.Add(myRow);

DataGrid1.DataSource = dsTemp;
DataGrid1.DataBind();

//Cache for later customer order additions
ViewState["DATA"] = dsTemp;

I like using a dataset because it contains built in functions to
automatically sum, total, find averages etc which come in very hand for
shopping cart type systems.
 
Back
Top