Forms Data Controls :: GridView Sort: Formview Not Rebinding?
Mar 15, 2010
I have a GridView and Formview attached to the same ObjectDataSource.
Everything is working ok so far.
If I enter new search criteria and click "Search", both the GridView and FormView rebind properly to the ObjectDataSource results. And I am able to page through the FormView records and they match the GridView records above.
When I click a sort link in the GridView, the ObjectDataSource returns the correct results based on the header link's commandName of 'Sort' and the CommandArg of 'SortExpression'.
The only thing wrong now is on the sort, the formview records do not reflect the reversing of the sorted record order. If I page through the FormView the records remain in the same order.
Why does the FormView not recognize the ObjectDataSource's changed results on the sort post back (even if it is only the sortExpression parameter of my ODS select method).
How do I get the FormView to rebind to the new ODS result set? I have called formview.DataBind() from every event I can think of. That does not seem to work either.
Just spent about 8 hours googling and looking through this forum for a solution on how to make sure that I can dynamically sort. Here is the situation.
I have 1 Gridview that displays 10 different scenarios based on what button is clicked.
I am also returning only top 10 records. I am doing all of the data binding pragmatically. So I have BoundFields, HyperLinkFields etc.
I also want to sort some records. When I change DataSource SQL statement the gridview somehow remembers what the last sort value was and it errors out saying that value "x" cannot be sorted because it does not exists.
Here I get an error that says that the data source does not support sorting? Doesnt it say gridview1.allowsorting = false;
I also tried gridview1.sort("", SortDirection.Ascending); This does nothin... except query my database one more time because i have a onSorting event that looks like this:
[Code]....
Here is an example of just one of those SLQ statements inside GetSQLQuery:
I am able to dynamily bind my grid to the cube based off the facillity I have selected. Now, if a facility has multiple cubes, I want the users to switch between the two cubes dynamicly, so I have created a drop down list showing their cubes and the ones that they can select. Currently I'm been trying several things in order to "rebind" the data but they don't seem to be working, so I figured I would attach my code to see if anyone Had a good idea.
If I make the cube change then switch back over to change facility and then back to the page, the new cube will load. So I have to find a way to do it in the one step rather then have them navigate to another page and then back again. Perhaps auto navigate them to a page and have that page send them back etc... Anyway here is the code: I first bind the data via the page_prerender call
[Code]....
Then the code drops down into the LoadCube(FacilityID) sub routine
[Code]....
Then here is the setup for the subroutine that will call the page load/ should change the cube to the correct cube.
I have a text box in a FormView that I use to display the return value from the stored procedure that I'm using to maintain the data. For assorted reasons, I'm not able to use the built in ability of the FormView to manipulate the data.
I have the following code at the end of the procedure that calls the stored procedure. It is a snippet that omits the bulk of the procedure.
[Code]....
As is, the label text is updated with the message. However, when I uncomment out the code that manipulates the SQL Data Source and rebinds the FormView, the label text is NOT updated. I can't figure out why it craps out.
1) AdvisoryMessageText is declared at the class level for the code behind, so it should be retaining the value across all of the procedures as their caloled.
2) TextBoxAdvisoryMessage is contained within the FormView EditTemplate.
I created a GridView that uses a custom paging method that allows for alphabetical paging. I seem to be having some problems now rebinding the GridView after a delete occurs. The row is deleted, it's just that the rebinding doesn't happen so to the user it looks like the delete failed. Been over and over my code and can't understand why. See the final block which is supposed to fire on the GridView1_ItemDeleted event.
I have a gridview with data. I want a button which is not part of the gridview. Then if I press a button the gridview is sorted by two colums. i.e column1 ascending column2 descending.
I am not looking to work with a Sqldatasource as I use a data access layer. So the sort would have to be from a datatable and databind or directly with the gridview.
I am working with a formview edititemtemplate. Currently in my page load, i have some stuff that would show or hide certain panels based on dropdownlist values. These dropdown values get binded during page load. I need to be able to change the values/dropdowns, without rebinding the old data, and updating the visibility of the panels based on predefined rules.
I have experimented with putting my formview.databind() in page load if isnotpostback, in prerender, in prerender if isnotpostback. I have tried my rules (ex if ddlState.selectedvalue = "DE" then pnlDelaware.visible = "true") in the page load, and the page render. I'm just not sure how to get the stars aligned here. The closest i have come is having the databind in the pageload if notispostback, and the rules in the prerender. However I get an error "dropdownlist has a SelectedValue which is invalid because it does not exist in the list of items.
I want to create simple rating page where player's place,name and rating is displayed. I've created database with ID,Name and Rating Columns, binded Gridview to this database and created TemplateField "Place". With following code I've created numbered list for Place:
protected void Page_Load(object sender, EventArgs e){ for (int i = 0; i < GridView1.Rows.Count; i++)
I'm a newbie to .NET, so the solution might be really trivial. I have a database, I have an Entity Data Model, I add in my Index.aspx page an EntitryDataSource and a GridView. I connect them and everything works fine (the data is displayed as expected). The problem is that clicking on the coulmn name or on the pagination lists doesnt do a thing... Although I did set the properties AllowSorting="True" and AllowPaging="True". I also tried with another datasource type (SqlDataSource) and the same problem.
i am having a gridview in which all columns get dynamically added, i applied sorting in it, all column added as boundcolumn get sort properly but two column which are added as templated column do'nt get sort. Though my dataview have these column as it is.
I am using gridview created by visual components. I have registered gridview_onsortclick event during the page initialisation, but when i try to click on the header of any column, this event does not get fired at that time. This event gets fired only after all the controls, sorting query is generated, filling the current dataset is done. But the same event is getting fired before query is generated and dataset is filled,for the other page. And one more thing to add with it, I want the sort function to be done on the whole dataset regardless of current page. Why is there such a difference in both the pages?
Is there a way to Sort a Gridview by a Calculated Column? I have a gridview with template fields using lablels and a linq datasource. Those columns sort just fine. I can not get the Calculated column to sort, because there is no sort expression to use...
I'm using asp.net 2 and would like to add sort direction arrows to GridView column headers.Please could someone point me to a soluton, VB.Net if possible.
Tried several different ways to do this but am just not seeing it. Proably a quick solution for someone more skilled than me.
I have a gridview generated from a datatable. One of the columns is "client name" whose data is generated from a class.
I added a link button for the column header that fires a sub that should sort the datagrid, but is not.
Here is the code I have so far that creates the gridview which works fine:
Private Sub PopulateCaseListGrid() 'Kill the existing DataSource, in case of a page reload gvCaseList.DataSource = Nothing 'Create a datatable with whatever column you want to use
I use Server.Transfer("pagename", True) to navigate from a page where two dates have been selected to a page with a gridview that uses the dates to query the database and display the results. The gridview initially displays correctly but when I operate the select or sort it disappears.