devexpress treelist changing datasource - devexpress

I have a treelist and I populate it with data in the load event of the form, it works.
In another form, I can add new values to the underlying data source. Then, I show the form again, which contains the treelist. In the load event, I perform the new query, also the data is the newest and I set the datasource to this new data. But the treelist is showing incorrect data. Why?
What am I missing?

Since there is no example of the code you are using, I'd suggest to use BeginUpdate() and EndUpdate() like this:
treeList.BeginUpdate();
treeList.DataSource = your data;
treeList.EndUpdate();
EndUpdate(): Unlocks the TreeList object after a call to the BeginUpdate method and causes an immediate visual update

Related

Flex, filter tree using ITreeDataDescriptor without reload and close all nodes

working with flex 4 and implementing filtering using ITreeDataDescriptor.
Filtering worked as expected like the following code snippet
however, i am trying to create a on-demand type of filter where user would type in the search clause in a TextInput, and as the user types, the tree nodes would be filtered on the fly.
my implementation now is have user click on the search button and then reapply the dataDescriptor then reload the data. A big problem is that the whole tree collapses after setting the dataProvider again.
any suggestion on how the on-demand filter can be achieved?
var dataFilter:ServicePricingFilter = new MyFilter();
dataFilter.searchString = this.txtSearchKeyword.text;
this.treeService.dataDescriptor = new MyDataDescriptor(dataFilter);
this.treeService.dataProvider = getTreeData();
I think you shouldn't set the dataprovider every time but use insted the filterFunction property available for ListCollectionView classes (ArrayCollection, XMLListCollection,...)
looked at the post Florian mentioned.
on-demand filtering is done by using ITreeDataDescriptor and a filterFunction.
on keyup event of the search TextInput, call invalidateList() function on the tree.
see the source code provided for the following post
http://www.davidarno.org/2009/04/01/how-to-filter-all-nodes-of-a-flex-tree-component/

How to bind to a control within an ASP.NET ListView

I have a list that I need to bind to a List I get from an API. The list looks like this:
struct DataItem { int level; string name; Guid key };
List<DataItem> myList = API.GetList();
ListView1.DataSource = myList;
ListView1.DataBind();
All this works fine for display. However, the table must edit the level value. I am unsure how to make that happen. I have tried event handlers on the listView, but they are never called. I have tried a text box for the level field (with both Bind and Eval) and an event handler OnTextChanged, but the event handler is never called. (I have tried with various combiniations of AutoPostBack and ViewState enabled.)
How can I programatically edit this data structure?
Two way data binding you are trying to implement here won't work like this - List doesn't implement INotifyPropertyChanged (someone correct me if I'm wrong).
You may consider using a plain old DataTable which can be two-way-bound out-of-the-box. If performance is not a highly critical issue, converting your List to a DataTable (and back, depending on what you want to do with the modified data) is simple enough, rather than struggling with custom implementations of list types.

Databound DataField not getting populated

I'm currently analyzing the code behind for a web application. The Default page contains a GridView with several bound DataFields that are supposed to be populated, when the page loads and reloads, with data based on a URL parameter that's passed on initial load. The way it works in summary is this:
-I have a GridView1_Init method that is called when the page loads, this retrieves data using an OldDbConnection and a URL parameter appended as part of the OleDbCommand SQL statement.
-The data is read and stored in the Web.config file. At this point, when debugging, I can see and verify the there is data being retrieved.
-Now I'm calling a GridView1_RowDataBound method to populate each row. I have it in the Default.aspx page within the GirdView parameters as OnRowDataBound="GridView1_RowDataBound"
My problem is that this method never gets called for one of the URL parameters I'm passing and as a result the Databound rows in the GridView don't get populated and the page displays nothing. I have another URL parameter I use to test and it works perfectly with that one, i.e. the page loads with the Gridview displaying all the data as expected. I'm not sure why the method GridView1_RowDataBound is getting called for one URL parameter, but not for the other. I've debugged using both and also ran the query in SQL Server Management Studio and I am getting data back for both. Thanks in advance for your help.
I'm not sure.. but try these 1-on the page load define a GridView1.datasource=....;
GridView1.Databind();
2-check the html tags are formed correctly.
Ok, I did a little more digging using Visual Studio and SQL Server Management Studio and first determined that the gridview was using a different stored procedure, than the one I was referencing, to populate the grid. Second, after rummaging through the database, I discovered that the table being referenced for data to populate the grid was empty. After inserting some test data, I went back and reran the application and finally had some data being displayed in the grid. Always the little things.

list box control in asp.net

Hello friends I have a list box control in my asp.net project.
I want to know how to get selected index to set currently updated item in database.
Please help me with this. Do i need to perform some data base operation to find the key for currently updated data and then i'll have to set it or there exist some property to deal with this? thanks in adavance
One thing to watch out for, which I have come accross more than once is that if you call your CompanyListBox() method in your Page_Load method, you will lose the selected index unless it is only called on the first page load. To make sure of this, place your call to CompanyListBox() within the following block:
if(!Page.IsPostBack)
{
CompanyListBox();
}
You can access the selected index in your postback by using the following code:
var id = (Int32)listCompany.SelectedItem.Value
Then it is up to you to use that in your data access to update the record in the database. Looks to me that you are using some kind of framework or manager class for your database access. The companyManager should have methods for saving your updated item to the database. Good luck.

How do I set up ObjectDataSource select parameters at runtime

I'm trying to add parameters to an objectDataSource at runtime like this:
Parameter objCustomerParameter = new Parameter("CustomerID", DbType.String, customerID);
Parameter objGPDatabaseParameter = new Parameter("Database", DbType.String, gpDatabase);
//set up object data source parameters
objCustomer.SelectParameters["CustomerID"] = objCustomerParameter;
objCustomer.SelectParameters["Database"] = objGPDatabaseParameter;
At what point in the objectDataSource lifecycle should these parameters be added (what event)? Also, some values are coming from a master page property (which loads after the page_load of the page containing the objectDataSource).
Add them to the event for the operation you are trying to use. For example, if these parameters are part of the SELECT command then add them to the Selecting event, if they need to go with the UPDATE command then add them on the Updating event.
The ObjectDataSource raises an event before it performs each operation, that's when you can insert parameters (or validate/alter existing parameters).
Also, don't try and modify the parameters collection of the ODS itself. You want to add your parameters to the ObjectDataSourceSelectingEventArgs that is passed to the event handler.
Something like:
e.InputParameters["CustomerID"] = customerId;
e.InputParameters["database"] = dbName;
Add as early as possible; at the PreInit event. This is part of initialization so should be done there.
See the ASP.NET Page Life Cycle Overview for more information.

Resources