ASP.NET DataGrid

Posts   
 
    
omar avatar
omar
User
Posts: 569
Joined: 15-Oct-2004
# Posted on: 12-Oct-2005 12:52:11   

Greetings, In a webform, I am trying to bind an OrderDetails collection to an Ms-DataGrid. At design time, I drag an Orders collection (dsOrders), then I set the grid's data-source to (dsOrders) (the grid automatically displays all the columns of dsOrders); then I want to set the DataMember to OrderDetailsCollection member of the orders collection. The DataMember property's dropdown does list any member-collections of the dsOrders collection. 1- should I set the DataMember property to OrderDetailsCollection manually (if so, this meens I have to define the OrderDetails columns manually to the grid) Is design-time binding broken in ASP.NET 2- Is there away to have the same design-time support we have for winform's data-grid in asp.net's data-grid

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 12-Oct-2005 13:09:30   

omar wrote:

Greetings, In a webform, I am trying to bind an OrderDetails collection to an Ms-DataGrid. At design time, I drag an Orders collection (dsOrders), then I set the grid's data-source to (dsOrders) (the grid automatically displays all the columns of dsOrders); then I want to set the DataMember to OrderDetailsCollection member of the orders collection. The DataMember property's dropdown does list any member-collections of the dsOrders collection. 1- should I set the DataMember property to OrderDetailsCollection manually (if so, this meens I have to define the OrderDetails columns manually to the grid)

You should drag an orderdetailscollection onto the form, design the grid, and bind an orders collection at runtime, setting the datamembers to "OrderDetails".

VS.NET's asp.net editor in vs.net 2003 doesn't work very well.

Is design-time binding broken in ASP.NET

Yes. "MS way or the highway".

2- Is there away to have the same design-time support we have for winform's data-grid in asp.net's data-grid

I wish there was, unfortunately, databinding is still not implemented as you would want it to be. In VS.NET 2005, asp.net databinding gets even worse.

Frans Bouma | Lead developer LLBLGen Pro
omar avatar
omar
User
Posts: 569
Joined: 15-Oct-2004
# Posted on: 12-Oct-2005 13:27:50   

what if I want to bind a DropDownList so that it gets populated from a dsCustomers collection but it gets its value from the Order object's m_order.CustomerId. I set the DropDownList's properties as follows: DataSource: dsCustomers DataValueField: CustomerId DataTextField: FullName these properties populate the list fine, but how do I bind to control to the m_order.CustomerId

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 12-Oct-2005 15:56:46   

it gets populated from a dsCustomers collection but it gets its value from the Order object's m_order.CustomerId

What do you mean by it gets its value? do you mean the selected value?

omar avatar
omar
User
Posts: 569
Joined: 15-Oct-2004
# Posted on: 12-Oct-2005 21:09:03   

yes.. in windows forms I know that I need a collection to populate the list part of the drop-down list (the collection part populates the list and its Display-member/ value-member properties decide its behaviure). But the drop-down list control itself has to be bound to a field property from the from's data-source. Example: a web-form that displays an (orders) entity object has one text box and two drop-down controls. txtOrderId: bound to m_order.orderId ddlCustomerId: should be bound to m_order.CustomerId but the list populated from a customers collection ddlEmployeeId: should be bound to m_order.EmployeeId but the list populated from a employees collection. The point here is how to bind ddlCustomerId and ddlEmployeeId to m_order.CustomerId and m_order.EmployeeId respectivly.

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 13-Oct-2005 03:07:37   

I believe you would need to fill separate Customer and Employee collections and then bind these to the dropdownlists. After this you set the dropdownlist value to the value that is contained in the order entity. If you are not interested in changing the employee or the customer, but just showing their information then I would use text boxes and bind them to the orders related entities and fill those related entities when the form is bound using a PrefetchPath of the order.

omar avatar
omar
User
Posts: 569
Joined: 15-Oct-2004
# Posted on: 13-Oct-2005 08:49:36   

bclubb wrote:

I believe you would need to fill separate Customer and Employee collections and then bind these to the dropdownlists. After this you set the dropdownlist value to the value that is contained in the order entity. If you are not interested in changing the employee or the customer, but just showing their information then I would use text boxes and bind them to the orders related entities and fill those related entities when the form is bound using a PrefetchPath of the order.

Thanx bclubb. Thats what I have done so far. The solution for my situation was to populate the dop-down list from seperate collectios prefetched with the m_order object. Then bind each drop-down control's SelectedValue to m_order.CustomerId and m_order.EmployeeId respectivly.

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 14-Oct-2005 02:35:57   

Cool, I'm glad you have it working now. simple_smile