.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Kaviya Balasubramanian
Imran Ghani
Post New Web Links

Custom Headers in Gridview, need to be able to sort

Posted By:      Posted Date: September 14, 2010    Points: 0   Category :ASP.Net
 
I have a Custom Header that I need to beable to sort.  The headers consist of a Textbox (for entering a search value) and a Linkbutton to fire the event.  I just need to know how to point that button to the sort function of the gridview. Thank you for the help,


View Complete Post


More Related Resource Links

Tooltip for GridView Column Headers (ASP.Net)

  
I just wanted to add auto tooltips for my GridView headers. There are couple of ways but I don't want to use javascript and wanted to use simple 'title' attribute. It took couple of hours to get the working code supporting sortable columns. I thought it will be very useful for others. Here's the code and logic behind it.

Scrollable GridView with fixed headers in asp.net C# vb.net

  
In this example i am going to show how to create scrollable GridView with fixed headers which don''t get scrolled with records and stay on the top in asp.net using css, I''ve tested this code on IE7 and Firefox 2.0 , 3.5.

For this we need to add css to headers of gridview to keep them on the top.

First of all place a Panel on the aspx page from thetoolbox. Set height to 200px and width to 200px
and scrollbars to Vertical.
Now add a gridview inside this Panel and set the datasource to populate gridview.

How to sort GridView?

  
In this article I will discuss how to sort columns in grid and more. At the end it will help answer some very frequently asked questions like following

Sort by gridview SortExpression parameter via Stored Procedure

  

I have a gridview that calls data via a stored procedure.  I am unable to enable the gridview columns to be sortable. I need to set the parameter in the Stored Procedure, can someone help me with this?

Here is my gridview:

<asp:GridView ID="AllUsersGrid" runat="server" AutoGenerateColumns="False" DataKeyNames="UserName"
                        GridLines="Vertical" Width="900px" DataSourceID="SqlDataSource1" AllowSorting="True"
                        SelectedRowStyle-Height="30px" CellPadding="4" BackColor="White">
                        <Columns>
                            <asp:TemplateField HeaderText="Full Name" SortExpression="lastname">
                                <ItemTemplate>
                                    <asp:Label ID="DisplayName" runat="server" Text='<%# Eval("firstname").ToString() & " " & Eval("lastname").ToString() %>' />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField HeaderText="User Name" DataField="UserName" />
                            <

Custom Grid View Header - Grid view Row Created event vs Gridview row databound events ?

  

Hi Gurus ,

It happened to add an extra Gridveiw Header in row_databound event , It did worked fine on !Postback but disappered on Page.Postback . Quick google search guided me to move the event to Row_Created event and every thing is okay .

Can any expert post some pointers , differnces between grid row_created vs row_databount with some sample table data created dynamically  behaviour of both the events in !Postback and page.Postback .

Thanks a tonne in Advance and  any inputs will be valued and appreciated .


How to Add Custom SOAP Headers Into The Server Response Message in WSE3.0?

  
Hi Dear All, Assuming I am the service provider, may i know how many ways are there to insert a custom header into the server response message? So far I tried several ways, and it can be done in custom SoapFilters (by playing with SOAPEnvelope object), and SoapExtension (SOAPMessage object). Just wondering if this could be done at web service class by specifying a SOAPHeader attribute, just like adding a SOAPHeader into the SOAP request message at consumer side? If can, it might be much smarter than SoapFilter and SoapExtension.   Thanks in advance!   Best Regards, Charles

Custom Sort Values in a Group

  
Hello, I have a dataset from cube. Please assume the data is similar to below State  Product Sales CA      Bikes    100           Cars     10 MN    Trucks    16 GA    Cars      10        Boats       25   This is represented in a simple tablix and a group is formed on the State. I want to provide a custom sort order on the grouped field lets say i want GA first, followed by CA and then MN. How do i design such a solution? Thank you in advance for your advice.      

Custom DynamicData Default.aspx GridView

  
On the Default.aspx page the GridView control is populated programmatically by setting its Datasource to a list of table objects. Is there some way I could populate this GridView manually using my own set of NavigateUrls and DisplayNames?Simon

Styling of GridView with Multiple Headers

  
Hi,    I want to implement GridView with multiple headers in  WPF. The requirement is such that GridView should show the headers as shown below: Detail info Name ID PhoneNumber   The sample Xaml Code with  which I was able to attain the above GridView presentation of Headers is given below:   XAML code: <Window x:Class="WpfNestedHeaderListView.Window2"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     Title="Window2" Height="300" Width="300">     <UserControl.Resources> <CollectionViewSource       x:Key="PatientInfo"       Source="{Binding Path=DocContext.PatientInformation}"/>   <Style x:Key="HeaderStyle" TargetType="{x:Type GridViewColumnHeader                <Setter Property="Template">                 <Setter.Value>                     <ControlTemplate T

styling of gridview with multiple headers

  
Hi,    I want to implement GridView with multiple headers in  WPF. The requirement is such that GridView should show the headers as shown below: Detail info Name ID PhoneNumber   The sample Xaml Code with  which I was able to attain the above GridView presentation of Headers is given below:   XAML code: <Window x:Class="WpfNestedHeaderListView.Window2"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     Title="Window2" Height="300" Width="300">     <UserControl.Resources> <CollectionViewSource       x:Key="PatientInfo"       Source="{Binding Path=DocContext.PatientInformation}"/>   <Style x:Key="HeaderStyle" TargetType="{x:Type GridViewColumnHeader                <Setter Property="Template">                 <Setter.Value>                     <ControlTemplate T

Styling of GridView with Multiple Headers

  
Hi,    I want to implement GridView with multiple headers in  WPF. The requirement is such that GridView should show the headers as shown below: Detail info Name ID PhoneNumber   The sample Xaml Code with  which I was able to attain the above GridView presentation of Headers is given below:   XAML code: <Window x:Class="WpfNestedHeaderListView.Window2"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     Title="Window2" Height="300" Width="300">     <UserControl.Resources> <CollectionViewSource       x:Key="PatientInfo"       Source="{Binding Path=DocContext.PatientInformation}"/>   <Style x:Key="HeaderStyle" TargetType="{x:Type GridViewColumnHeader                <Setter Property="Template">                 <Setter.Value>                     <ControlTemplate T

How do I access the custom headers created with System.Net.Mail?

  
I've created some custom headers for my emails.  I've used a breakpoint to see that they are being added to the collection correctly.  I don't understand how to access these from the email that's generated though.  I'm currently dropping the emails into a pickup directory on my local machine and viewing them with Windows Mail.  I have "view all" headers checked in Windows mail but still don't see them when I open my emails in the pick up directory.Can someone please tell me how to access the headers that I added?  Below is an example of how I did it.  I'm hoping to add things like name, address, phone... etc, and then have them visible in the email.   Is this even the correct use of custom headers? message.Headers.Add("X-Name", txtName.Text);  

Textboxes in Gridview Headers

  
I have a couple of Textboxes in a Gridview header, mainly used to search for items in the dataset.  This works fine; however, on Post Back, the textboxes do not hold the entered text.  The View State is enabled for these control items. Can someone point me in the right direction?

Keeping Custom properties in GridView Added on OnRowDataBound Event While Sorting

  
All of my columns are bound in the Gridview. On OnRowDataBound event, I am adding some custom styles like underlines and colors to the text of the columns. Sorting of data is working fine but I am losing my custom styles when I sort. I am using the generic sorting code for the GridView. How I can keep my custom styles on sorting that I added during OnRowDataBound event.   Thanks for your help.

Multiple column headers in Gridview

  
Hi,  I've been trying for the past few hours to add mutliple headers to my grid view but keep failing to get it to show.  There's plenty of examples online that I found but can't seem to get the most simplest to work.  Below is the code I've been using with no success.  I even tried changing the "TableCell" to "TableHeaderCell" but still yields no headers as expected.  Anyone know what I could be doing wrong? protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Header) { GridViewRow headerow = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert); TableCell headercell = new TableCell(); headercell.ColumnSpan = 3; headercell.Text = "My Custom Header"; headerow.Cells.Add(headercell); GridView1.Controls[0].Controls.AddAt(0, headerow); } }

How to sort # column in GridView (asp.net) ?

  

I have a GridView with a column that contains rows numbers. somethign like below :

#
------------------
1    |
2    |
3    |
.     |
.     |
.     |
11  |
12  |
13  |
.    |
.    |
.    |
-------------------

I've added it to the GridView with the following code :

<asp:TemplateField HeaderText="#" SortExpression="#">
<ItemTemplate>
<%# Container.DataItemIndex + 1 %>
</ItemTemplate>
</asp:TemplateField>


Now I wanna sort GridView with this column, I've done it by reading this thread. But when I sort the GridView by # column, it sorts the GridView like below :

#
------------------
1   |
11 |
12 |
.   |
.   |
.   |
21 |
22 |
23 |
.   |
.   |
.   |
-------------------

How can I fix it

best way to remove (or hide) a gridview column in a custom page

  

can someone tell what the best way to remove (or hide) a gridview column is within a custom page?

I dont want to show the link column that is automatically generated as a result of the relationship between the table in question and a parent table.

 

john


Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend