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

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

custom gridview

Posted By:      Posted Date: October 03, 2010    Points: 0   Category :ASP.Net

I have my table in ms sql server like this

Company_name     Country     

a_com                     Korea

b_com                     China 

c_com                     England

d_com                    Canada

e_com                   Korea

f_com                   England

g_com                 China

and I want to view my table in my gridview look like this

Korea      England         Canada   China

a_com      c_com           d_com      b_com

e_com      f_com                           g_com  

will you please provide my a code in vb.net or c# code behind. 

how can I do that? please help me I'll appreciate any help.. thank you in advance God Bless.


View Complete Post

More Related Resource Links

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 .

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

Custom Headers in Gridview, need to be able to sort

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,

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.

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.



Gridview custom paging using virtualitemcount



I wanted custom paging in gridview as we were using in datagrid with property virtualitemcount property,

but I am not getting the  virtualitemcount property in gridview.

i dont want to maintain it with datasource control in aspx page.


create custom pager for gridview


i dont like the inbuilt paging event used by gridview.i want to make an attractive pager like the one in http://www.htmlforums.com/f-client-side-scripting-6.html/

plz halp me

Reg: Creating custom gridview....


Can anyone give some sample code for the following ?

I want to create the custom gridview control to load page quickly. For example if I have 1,00,000 records , but i want to show only 20 records in a gridview control. If I use asp.net gridview then we need to load all 1,00,000 records and give the page size as 20.But it will take long time to load. Instead want to make gridview control of 20 records per page with 1,00,000 records paging logic without loading all the records.

Please let me know if any one have idea about this.


Adding controls to custom extended gridview



I have custom gridview that  inherit from the regular gridview.

On of the features is that is has a built in page size dropdown in an extra header row.

Another feature is that this extra header row has a place holder where aditional controls can be added but here is where I have some problems.

When I add a control that is created outside the gridview to the gridviews builtin placeholder and tries to do anything that performs a postback the gridview dissepears, but appears again on a new post back.

Here is the code for the gridview:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Security.Permissions;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Backend.BLL;
using Backend.DAL;
using Backend.IP;

namespace SharedGui
    public delegate void UpdateEventHandler();

    AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal),
    AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal),
    ToolboxData("<{0}:GridViewCustom runat=\"server\"> </{0}:GridViewCustom>"),
    Description("Extended gridview control")

Custom control inside a GridView


Hi All,

I have created a custom pager control for implementing paging which has four link buttons, two textboxes and two buttons in it. I have derived that control from a Panel and have implmented the INamingContainer and IPostBackDataHandler interfaces.

Every time I click on either LinkButtons or on buttons, the page gets posted back to the server and the LoadPostData method of IPostBackDataHandler gets called (as expected). But, the click event of the control that is cliked gets fired every alternate time.

E.g.: If I click on the LinkButton named 'First' for the first time, the click event handler will execute. Next time when I click on the same LinkButton, only the LoadPostData will get executed. Again, when I click on the same LinkButton, the event handler will execute properly. This pattern remains the same for all the buttons.

Please let me know if any one has encountered such a situation and what can be a solution to it.


Girish :)

Use GridViewPager for GridView in Custom Web Control



I Use dynamic data's gridviewPager for my GridView, where my gridview bind manually in code behind.

But the when i change the text in textbox (page no), or click on previous, back, next or last, the control is not working and my gridview is not updated to tat page i keyed in.

Please advice on that. Thx

Gridview custom paging ODS


I'm trying to come up with a simple way to alphabetically retrieve records from my database. I tried adapting this tutorial to my needs but it didn't work (I'm using VS Express 2010). I'm thinking that I'd rather have an objectdatasource alphabetically access the database through the business layer, and I wrote a specific method for that purpose (the table adapter query works at the dataset level).

But I'm not sure how to write the code to programatically display the letter links, then assign the chosen letter to the objectdatasource query, and also respond to postbacks, etc. as in the tutorial mentioned above.

I'd like to know if using objectdatasource to alphabetically bind data makes sense or complicates things and what would be the best way to go.

Thank you,



custom linq to sql statement gridview paging


Ok, I know this cant really be that hard, but im having trouble finding any info. I have a gridview on the page that i am filling with data based on a user selected date range(a dropdown list). When the user clicks the button i fill the gridview and display it. This is all done using Linq to Sql. I need to impliment paging and sorting as well. Help PLEASE!!! Below is my button click event... i am open to any suggestions to get this working


protected void btnGenerate_Click(object sender, EventArgs e)
        int dateRange =0;
        if (rbDateList.Checked)
            switch (ddlDateRange.SelectedIndex)
                case 0:
                    dateRange = 30;

Inplace Edit in GridView

In this article I am presenting a different way to look at EditItemTemplate, using which user navigation for editing is reduced and . it looks very different (see screeen shots) then regular implementation of GridView.

GridView Confirmation Box Using JQuery BlockUI in asp.net

JQuery is the most popular JavaScript library. One of the main reasons for its fame is the plugin architecture. Anyone can create a separate library that leverage the JQuery library. In this article we are going to look at the BlockUI library which is used to block the user screen while performing a task.

Custom Controls in C# .NET

Embedding user controls in a Windows form is just like adding a simple button or text box that are already provided with .NET. These basic controls were written essentially like you code your own controls. Typically the controls you design are to be used in multiple forms or to modularize your code. These reasons help reduce the amount of code you have to type as well as make it easier for you to change your implementation. There should almost never be any reason to duplicate code because it leaves a lot of room for bugs. So, implementing functionality specific to your control in the control's source code is a good idea. This reduces code duplication as well as modularize your code, which is a good programming guideline.

Textbox Editable GridView in ASP.NET

This article describes how I made a fully editable gridview in C# using ASP.NET 2. The idea is that the GridView looks and works like an Excel spreadsheet. You see all the cells in the table, and you can edit any of the cells you like, and they are automatically updated (i.e. saved to the database). This is very often how people expect data tables to work in web pages, and I've often seen people clicking in vain on un-editable gridview cells, somehow expecting to edit them, and not understanding that they need to click an Edit button at the end of the row.
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