Forms Data Controls :: Gridview (bound By ObjectDataSource) Sorting

Aug 31, 2010

I have a gridview being data bound by an objectdatasource which points to a BLL/DAL. I have paging and sorting enabled within the gridview. I have the fields configured in the look/fell I want from a templatefield. This templatefield has the sort expression (date) I want things to be sorted by. All this works as it should and I have no issues with it.But, the issue is that when I click on the header to sort asc/desc by date, I have to click on it twice for it switch to descending order. E.g. I hit the webpage and it lists all the information in the gridview, sorted by date, ascending order. If I want to sort by descending order, I have to click the date header twice in order for the gridview to sort the information in descending order; the clicks cause a post-back and the whole screen is refreshed.

View 2 Replies


Similar Messages:

Forms Data Controls :: GridView Bound To ObjectDataSource Not Populating

Jan 28, 2011

VS2010 Ultimate ASP.NET 4.0 Web Appliction project

I have a simple aspx page with a GridView Bound to an ObjectDataSource utilizing a class object that returns a DataView.

There are no errors generated, but the GridView does not display any rows. If I check the return value of the ObjectDataSource in the Selected event in the Immediate window (?CType(e.ReturnValue,DataView).Count), there are 51 rows. However, (?Me.GridView1.Rows.Count) shows 0 rows. The exact same page in VS2008, ASP.NET 3.5 works fine. how to get the GridView to display the rows? What has been done to the GridView in 4.0?

Page and code below -

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm2.aspx.vb" Inherits=".WebForm2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

[Code]....

View 6 Replies

Forms Data Controls :: Sorting A GridView That Is Populated By An ObjectDataSource?

Mar 11, 2010

I am having some difficulty enabling sorting on a gridview that has data in it that has come from an objectdatasource.

The AllowSorting="True" function doesnt work for ObjectDataSource so I need to find a work around...I am guessing that I will need to do something in code in order to get this off the ground.

View 4 Replies

Forms Data Controls :: ObjectDataSource - Custom Gridview Paging And Sorting?

Feb 4, 2010

ObjectDataSource - Custom Gridview Paging and Sorting?

View 2 Replies

Forms Data Controls :: Gridview Sorting Unbound Column In Bound Grid

May 14, 2010

I have a gridview control bound to a sqldatasource in c#. In the rowdatabound event I look at a value in a cell and use a function to evaluate the value and depending on that value I populate an added unbound column in my bound datagrid to show an excalmation point. I now want to sort by the column with the excalmation point.

View 2 Replies

Sorting Data With Gridview And ObjectDataSource?

Feb 2, 2011

how I do a sorting in a gridView with data bound by a ObjectDataSource?

View 2 Replies

Forms Data Controls :: Sorting With Listview Via ObjectDataSource?

Sep 30, 2010

I want to sorting via clicking header ( kod , aciklama, yeri, are headers ) with list view component and ObjectDataSource. ObjectDataSource use komponentListesi() method for selecting. How can i sorting with use listview component.

Data Object layer

[Code]....

Data Access layer

[Code]....

Listview

[Code]....

View 3 Replies

Forms Data Controls :: Handle Sorting And Paging When Objectdatasource Is Being Built Dynamically?

Sep 7, 2010

i am building my objectdatasource dynmically when certain buttons are clicked on the page.. and with that the gridview is being displayed with the results of the objectdatasource that was built.

So my gridview code looks like this:

[Code]....

How can i enable sorting and paging if the datasource is being built on button click event?

View 16 Replies

DataSource Controls :: ObjectDataSource Sorting And Paging In Gridview Using LINQ Stored Procedure Methods?

Jan 31, 2010

I started learning LINQ, So i thought of just creating gridview with sorting and paging using objectdatasource using LINQ. So i got this link

[URL] which Brian Orrel tell us how to do using IQueryable Interface. but i have nearly 300 lines of stored procedure which joins nearly 20 tables. so i thought of creating a stored procedure and using that instead of IQuerytable.

[code]...

View 7 Replies

C# - Sorting Gridview Bound To Linq SP

Oct 22, 2010

I have a grid bound to a linqed SP thus:

Session["results"] = db.spGetCaseByNumberOrSurname(txtCaseNum.Text.Trim(), null).ToList();
gvResults.DataSource = Session["results"];

on the sorting of it, i would like to be able to do this..

protected void gvResults_Sorting(object sender, GridViewSortEventArgs e)
{
string sortExpression = e.SortExpression;
List<spGetCaseByNumberOrSurnameResult> data = Session["results"] as List<spGetCaseByNumberOrSurnameResult>;
if (sd == SortDirection.Ascending)
{
sd = SortDirection.Descending;
gvResults.DataSource = data.OrderBy(d => d.GetType().GetProperty(sortExpression));
}
else
{
sd = SortDirection.Ascending;
gvResults.DataSource = data.OrderByDescending(d => d.GetType().GetProperty(sortExpression));
}
gvResults.DataBind();
}

sadly that doesnt do any sorting at all..it in fact errors with "The data source does not support server-side data paging."

View 1 Replies

Sorting Gridview Bound To Datatable In C#.net?

Sep 28, 2010

I have a gridview which is bound to a DataTable. When I try to sort the gridview, it goes blank. How can I enable sorting this gridview? I know this question has been asked before, but what I'm looking for is an explanation of how to do it. Perhaps with a simple example.

I have read that I need to put some code in the on_sorting and/or on_sorted events, but I don't understand what needs to go there. Again, I want to understand the method of accomplishing this, I don't just want a giant block of code.

View 4 Replies

Forms Data Controls :: Getting The Custom Sorting And Paging With Images To Indicate The Sorting Direction In Gridview

Jul 18, 2010

Moderators Note: THIS ISSUE IS BIG FOR ME AND EVEN IF POSSIBLE, GET THE REPLY FROM THE DESIGNER OF GRIDVIEW. I have been looking for him for long. I am really fed up with reviewing a good lot of web pages on how we can possibly customize the gridview to enable sorting and paging. So many sites have listed out a lot of information and so many guidances. But the problem is that one works out fine and the other is a burden. I really feel bad about being given the job of customizing this kind of a gridview which has no user friendly approach to it. Also, this control is rendered without the pager links inside the <tfoot> tag. I have tried the Pear Pager in php. It is that good and easy to use and compared to that, the gridview in asp.net is the worst ever control i have ever tried so far.

1. i can use the images to indicate the sorting direction
2. I can have the custom pager like

[code]

<<Previous 1 2 3 .. 7 Next >>.

[/code]

When i click the next when i am viewing the page at 3 , the pager links should change as

[code]

<<Previous 2 3 4 .. 7 Next >>

[/code]

Kindly look into this type of requirement and firstly tell me whether this is possible with the gridview control. I would like this request even to be escalated to the designers of the gridview control also, so that Microsoft comes out with a reply THAT WORKS and not the kind of stuff like surfing through a lot of links and pages and finally wasting a lot of days precious time and still breaking the head with this useless control. I have spent a lot of time in searching for a perfect way. Not writing a code that is non-standard. I am really serious b'cos I have spent weeks in customizing this control. If I dont get a solid reply atleast now, I am going to generate all the output by HTML content by custom coding.

View 7 Replies

DataSource Controls :: Sorting A ListView Bound To LinqDataSource Based On Child Object?

Jul 22, 2010

This was a pretty disappointing moment - when databinding, using Eval("Contact.LastName") would work. It nicely evaluates the related Linq object's member LastName. If the "Contact" object is null, no error is thrown... instead the field is simply null.

However, the same does not hold for sorting - if there exists a null entry (this object does not have a Contact) then the LinqDataSource throws a NullReferenceException. This means that, if you ever have nulls on your foreign-key objects, you can't use sorting headers in the ListView.

This makes the feature moderately useless - I have to roll my own properties for every single field I'd ever want to sort on. That's insane.

View 1 Replies

Web Forms :: How To Implement This Feature In Listview Control Which Is Bound To Objectdatasource

Jul 5, 2010

i want to implement this feature in listview control which is bound to objectdatasource... and in on mouse over i have to show the data from database again. when you mouse over the linkbutton then div popup with contents...how to imlement with listview.

link for the feature is

[URL]

View 4 Replies

Forms Data Controls :: Display A One Row Gridview When Gridview Is Bound To Empty Dataset

Jan 13, 2010

If the gridview binds to empty dataset, I need to still show a gridview so that users can ADD more using the textfields in the bottom of the footer template. Since the gridview is empty it won't bind not allowing rendering of the <footer template> I guess I should create a empty dataset if the gridview is empty. How do I check for this and can this be done in GridviewRowEventArgs

View 5 Replies

Forms Data Controls :: Selected Checkbox In Gridview Should Be Added From One To Other Gridview Using Objectdatasource

Aug 2, 2010

table a
a1 a
1 qw
2 asa

i have two grid views

gridview1 has check box[a1] and one value[a](in total two columns) with objectdatasource1 for datareferencing from database

another gridview2 has to select only the selected/checked value of gridview1 of checkbox1

View 3 Replies

Forms Data Controls :: GridView And ObjectDataSource - Column Is Not Shown In The GridView's List ?

Feb 9, 2011

I'm facing a wierd problem with GridView and ObjectDataSource. I bind GridView to my business objects via ObjectDataSource. Everything was working fine until I decided to add a new field in my buisness object and wanted to add a column to GridView to show it. Somehow that column is NOT shown in the GridView's list of available columns. I have tried refreshing schema, rebinding, etc. I'm using GridView inside a user control which is used as a web part. Does that make a difference ?

View 3 Replies

Forms Data Controls :: How To Get The Row Value Of Gridview Upon Bound

Jul 2, 2010

I got his code for RowDataBound

[Code]....

View 4 Replies

Forms Data Controls :: Gridview Sorting Failed If Multiple Gridview Are Created

Mar 10, 2011

I got a web page, it has a tabcontainer, within each tab, there will be a gridview, all the tabs and gridview are created at run-time, i have only one code, that I will loop through to create all those tabs and gridview. When I apply the sorting, and I click on the column name on any grid, it returned an error saying index was out of bound. BUT, when there is only ONE grid view created, it is working fine, I suspect it mixed up all the grid view's id and so on. But I have assigned different ID to gridview

View 8 Replies

Forms Data Controls :: Sorting A Gridview Using Linkbuttons Situated Outside The Gridview?

Jan 14, 2010

I'd like to sort a gridview using linkbuttons situated outside the gridview. For instance :

[code]....

View 3 Replies

Forms Data Controls :: Get ID Bound To Label In GridView?

Feb 10, 2010

I have a foreign key (TeamID) in a GridView. I use a TemplateField to display it as the lookup value (TeamName) in a label, and a dropdown for editing. When row is selected and SelectedIndexChanged is fired, I want to access the TeamID. I can get the TeamName from the label. I tried putting the TeamID in DataKeyNames, but that fouled up my dropdown when saving (it reverts to the original value). So, how can I get the TeamID?

View 1 Replies

Forms Data Controls :: Gridview Inside Another Gridview Both Sorting - Using 3.5 Visual Studio 2008 C# Code Behind

Apr 16, 2010

I have the gridview inside another gridview, i want to sort that both gridviews, I don't know how to achieve using asp.net 3.5 visual studio 2008 c# code behind. Following are my aspx page,

<div
id="divclm"
runat="server">
<asp:GridView
ID="claimgrid"
runat="server"
AutoGenerateColumns="False" AllowSorting="True"
Width="100%"
AllowPaging="True"
CssClass="gareahead"
EmptyDataText="No Records To Display"
OnRowDataBound="claimgrid_RowDataBound"
OnRowCreated="claimgrid_RowCreated"
GridLines="Both"
OnPageIndexChanging="claimgrid_PageIndexChanging"
OnSorting="claimgrid_Sorting"
CaptionAlign="Right">
<Columns>
<asp:HyperLinkField
Text="<img id='upimg' src='Styles/Images/appschg.gif'/>"
ItemStyle-Width="10px">
<ItemStyle
Width="10px"
/>
</asp:HyperLinkField>
<asp:BoundField
DataField="name"
HeaderText="Name"
SortExpression="name">
<HeaderStyle
HorizontalAlign="Center"
/>
<ItemStyle
HorizontalAlign="Left"
/>
</asp:BoundField>
<asp:BoundField
DataField="code"
HeaderText="Code"
SortExpression="code">
<HeaderStyle
HorizontalAlign="Center"
/>
<ItemStyle
HorizontalAlign="Left"
/>
</asp:BoundField>
<asp:TemplateField>
<ItemTemplate>
</td></tr>
<tr>
<td
colspan="6"><div
id="<%#Eval("code") %>"
style="display:none;position:relative">
<asp:GridView
ID="Gdclmline1"
runat="server"
AllowPaging="True"
AllowSorting="True"
AutoGenerateColumns="False"
OnSorting="Gdclmline1_Sorting" BorderColor="Green"
BorderStyle="Solid"
BorderWidth="1px"
OnRowDataBound="Gdclmline1_RowDataBound"
OnRowEditing="Gdclmline1_RowEditing" Font-Names="Verdana"
Font-Size="8pt"
Font-Strikeout="False"
OnSelectedIndexChanging="Gdclmline1_SelectedIndexChanging"
OnRowUpdating="Gdclmline1_RowUpdating" PageSize="1000"
RowStyle-Wrap="false"
Width="100%"
CssClass="gareahead"
EmptyDataText="No Records To Display"
GridLines="Both">
<PagerSettings
Mode="NextPreviousFirstLast"
NextPageText="Next"
Position="Top"
PreviousPageText="Prev"
/>
<Columns>
<asp:TemplateField
HeaderText="phone"
SortExpression="phone">
<HeaderStyle
HorizontalAlign="Center"
/>
<ItemStyle
HorizontalAlign="Left"
/>
<ItemTemplate>
<asp:Label
ID="lblphone"
runat="server"
Text='<%#Bind("phone") %>'> </asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField
HeaderText="address1"
SortExpression="address2">
<HeaderStyle
HorizontalAlign="Center"
/>
<ItemStyle
HorizontalAlign="Left"
/>
<ItemTemplate>
<asp:Label
ID="lbladdress1
runat="server"
Text='<%#Bind("address1") %>'> </asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle
CssClass="gr"
Height="100px"
HorizontalAlign="Left"
Wrap="true"/>
<SelectedRowStyle
CssClass="gr"
/> <PagerStyle
CssClass="gareahead"
HorizontalAlign="Left"
Wrap="False"
/> <HeaderStyle
CssClass="ghead"
ForeColor="White"
Wrap="true"
/> </asp:GridView>
</div>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerSettings
Mode="NextPreviousFirstLast"
NextPageText="Next"
Position="Top"
PreviousPageText="Prev"
/>
<HeaderStyle
HorizontalAlign="Center"
VerticalAlign="Middle"
CssClass="ghead"
ForeColor="White"
/>
<RowStyle
CssClass="gr"
/>
<SelectedRowStyle
CssClass="gs"
/>
</asp:GridView>
</div>

that aspx page contains gridview that contain one more gridview inside in it.Now i want to sort out both the grid i.e)claimgrid and Gdclmline1 i want code in c#.

View 3 Replies

Forms Data Controls :: GridView Sorting, Paging And DataBinding / When Control Causes A Postback GridView Is No Longer Sorted?

Jan 10, 2011

I'm trying to extend the GridView control to enable sorting and paging for any situation.

When using my control I am fetching data from a database and filling a DataSet with it, then binding the GridView upon every page load. My first question would be, is this the correct approach?

To sort the GridView I am overriding the OnSorting method which stores the sort expression and direction in the ViewState, then creates a DataView and utalises the Sort method to sort the underlying data. It then sets the Data Source to this DataView and rebinds the GridView.

Paging is handled by OnPageIndexChanging which simply sets the PageIndex property and again rebinds the GridView.

My problem is; when any control causes a postback my GridView is no longer sorted, presumably because it is persistently rebound. If I don't rebind it then the GridView is empty on postback since the data isn't automatically stored in the ViewState. I have considered saving the data source in the ViewState but I would assume that this is bad practice for large amounts of data? - also DataViews are not seralisable.

The only solution I can think of currently is to override OnDataBound and sort the data every time. This results in a double sort when paging triggers a postback which seems inefficient. Code illustration of this below,

[Code]....

I'm looking for the cleanest 'best practice' solution as this is a learning exercise more than anything else.

View 12 Replies

Forms Data Controls :: Edit GridView Row With ObjectDataSource

Sep 21, 2010

I have a grid that receives products over a GetList methods via ObjectDataSource. The Product class contains also a Object Supplier. If I change in the drop down list of the grid the supplier for a product and I click update the ID of the suppliier is still the same. I have debugged the call of the update method and checked the parameter in the product object. I wrote the following code in the SelectedIndexChanged event and the text box shows the right id but not the update method.

DropDownList supplier = (DropDownList) sender;
txtTest.Text = supplier.SelectedValue;

Here is the code of my grid view:

[Code]....

My Object Data Source calls the following Update Method:

[Code]....

The next work around idea would be to call the update method manually in the Update Event of the grid view.

View 3 Replies

Forms Data Controls :: GridView With ObjectDatasource+Update

Mar 19, 2010

Can you post of an example of Gridview with EditItemTemplate using ObjectDataSource as data connectionand Update the the specific row. Ihave lots of sleepness night with this problem.

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved