Hello,
I am running into the issue described in the subject line. I have an UltraGrid in my WinForm application to which I bind a DataSet coming from a custom business object (e.g
gv.DataSource = BAL.Orders.GetAll()gv.DataBind();
)
The embedded Dataset that is returned has an embedded DataRelation object which associates an EmployeeID and ProcessingDate between the two tables that the DataSet contains and as such displays appropriately showing the first DataTable data in Band[0] and the second DataTable data in Band[1].
In the InitializeLayout Event however I am running into a problem where I am referencing a particular column in the grid (and that data in this particular column is not one of the data elements that make up the embedded DataRelation of the DataSet, but rather just one of the several columns that the first DataTable displays in the Grid band[0] columns) .
The issue I am encountering on build is an ArgumentException - was not handled. Key not foundParameter: key
.... when I make a reference to the column which I am setting up to use in a Summary in the Grid's header. Here is my code:
UltraGrid
gv = this.gvCompanyEarnedHours;UltraGridBand band0 = gvCompanyEarnedHours.DisplayLayout.Bands[0];UltraGridColumn colActual = band0.Columns["ActualHours"]; <-- Exception hereUltraGridColumn colEarned = band0.Columns["EarnedHours"];
//SummarySettings _settings1 = band0.Summaries.Add("SummedActual", SummaryType.Sum, colActual);//SummarySettings _settings2 = band0.Summaries.Add("SummedEarned", SummaryType.Sum, colEarned);// gv.DisplayLayout.Bands[0].Summaries["SumActual"].Appearance.TextHAlign = HAlign.Right;// gv.DisplayLayout.Bands[0].Summaries["SumActual"].DisplayFormat = "{0:###.#}";
I am at a loss here as to why it would be complaining about some missing parameter key? This has been an absolute shopstopper for me, short of pulling of my hair out.
Thanks,Paul
Hello,
I am just checking about the progress of this issue. Let me know If you need any further assistance on this issue?
Thank you for using Infragistics Components.
Hello ,
I have tried to reproduce your issue on my machine, based on the description in this thread. So I have created a class, which retrieves a DataSet object. I am binding this DataSet object to the UltraGrid and also have handled InitializeLayout event of UltraGrid and I am iterating trough all bands and columns in order to populate a tree with the keys of the bands and columns. Please see the attached sample. As you can see each column has a key.
Please let am know if I am missing something.
Hi Hristo,
I am really not sure I undertand what you mean by isolating a small sample without sending you all of the code related to the operation that binds to the UltraGrid, save for just recommending you try the following:
1) Create DAL class and add a method that returns a DataSet - the method should call a stored procedure that consists of two select statements (select x from Products select y from ProductDetails)
2) Create Business Layer class that calls the DAL class, and method that returns the Dataset which itself returns a DataSet, but prior to returning the DataSet sets up a DataRelation object that associates the data in the first datatable inside the DataSet with the second datatable inside the same dataset, e.g.
public static DataSet getProductDetails(){
DataSet _ds;_ds = DAL.getProductDetails(); DataRelation dc = new DataRelation("ProductView", _ds.Tables[0].Columns["ProductID"], _ds.Tables[1].Columns["ProductID"], false);_ds.Relations.Add(dc);return _ds;}Assuming your Biz Class is called Product, at the UI level do the following in code (Assumes an Ultragrid has been defined in the form) and in the event most appropriate
protected void WinForm1_Load(.....){ugProducts.DataSource = Product.getProductDetails();}
Also add an InitializeLayout event for the grid ugProducts_InitializeLayout(sender, event)
And inside the Initialize_Layout method try adding one of the 1st or 2nd band's Columns to a Watch window, and specifically looking for the "Key" value in either band's columns - or try to read out the key of a given column and when hitting that line hover over it to see the value of the Key
In all my cases the "Key" s for all my columns are empty. I am doing nothing special to the UltraGrid just simple binding the control from a class method.
3)
I am glad to hear that you were able to find a solution for your issue.
If you isolate your issue in a small sample, in order to be able to reproduce it on my machine, I will try to find the exactly reason, which causes this issue and will be able to give you more specific and appropriate advices for improving of your code, if it could be improved.
I am waiting for your feedback.
Hi Hristo. Actually I went with a work-around that essentially loops through the first of the two datatables inside the dataset that I am binding to the grid to get my values and then adding them to labels above the grid.
In looking at previous responses I follow what Mike is saying, only the part about telling the grid which resultset I am binding to is not applicable in my case because the goal is to bind both datatables in the dataset (creating two bands) and use of a DataRelation to set the relational fields which is done my business object before the DataSet is returned.
Ideally though, if you guys have a good sample I can look at, that would be great in the event I have to deal these summaries on columns again. Also if the sample could include the SetDataBinding method implementation that would be helpful too.