Custom DataGrid

H

Hermit Dave

Hello people,

This is my second post. Someone answer it...
Okay I had issues with using DataGrid control that comes by default. Had
some paging issues and also needed sort and filter to be added. Realised
that I need to write the code myself. So I got myself to building my custom
control.
It is not a composite control. I am drawing everything.
Was earlier thinking of using Repeater control but that would mean asking
the end user (me again) to do some extra stuff plus it was a pain cause sort
is normally done on column names and with repeater they aren't a part of it.
(meant scattered code if I don't make my own control)
anyhow
planning to use the ITemplate object to get info which would be similar to
DataGrid definition.
The problem is that I have know clue as to how Columns property is
implemented. Looked up the documentation and its some sealed class. Which
means not helpful at all.
* And how can I allow the user to use property builder to create columns and
specify paging info etc. What do I need to do ? any idea ?

Thanks a lot,

Regards,

HD
 
J

James Radke

HD,

Why would you need to create your own control to use custom paging, sorting
and filtering?

You can do all of these items fine with the existing datagrid: although
this does require that you do create some of your own code in the codebehind
module. I have several pages where I have 5 or so textbox/drop down lists
that allow the user to select their filtering criteria, and also enable the
headings of some of the columns to allow them to change the sort order from
asc to desc, etc...

What kinds of problems were you having? What, exactly, were you trying to
do? More information would be helpful....

Jim
 
H

Hermit Dave

Hello Jim,

Okay the problem is that at work we set up a monitoring system using ASP.net
Portal Starter kit.
When i try using Paging with Datagrid and the type is Numeric Pages with
values 10 with more to next set and previous set. When i move to the next
set of pager links and say click on page 17 it does pull the right records
but the pager is reset to 1 to 10 and if there are say more than 20 pages
there's no way to move beyond unless i change the code to do custom paging.
Okay i know DataGrid is configurable and okay it can supprt lot of different
things but have to write code behind for everything and at the end of the
day if i am to use it in more than one page... duplicate the effort. The
second reason why i got onto designing a control is that the datagrid is
currently used in 8 odd pages and most dont have enough records for now to
have paging issues but sort and filter is required.
Plus with control i can set it to capture even and so dont have to write any
code in code behind.

So what i did was started with plain vanilla table... used table to display
the records (at the end of the day even a data grid generates table
structure to display) Plus my own PostBack events for the column and handle
it on the control itself. The problem i am facing is that i am forced to use
the Column Headers in the Datasource. Plus i can't define say specially link
columns to say open the edit page. Stuff like that

<asp:DataGrid id=DataGrid1 runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn HeaderImageUrl="Order ID"
DataField="orderid"></asp:BoundColumn>
<asp:BoundColumn HeaderImageUrl="Order Date"
DataField="orderdate"></asp:BoundColumn>
<asp:HyperLinkColumn Text="Order Details" Target="_blank"
DataNavigateUrlField="orderid"
DataTextField="orderid"
NavigateUrl="OrderDetail.aspx"></asp:HyperLinkColumn>
</Columns>
</asp:DataGrid>

okay now Columns is a property on the DataGrid control. How would you go
about creating something like that,
Will probably get around to working on it in the monring. Thanks,

HD
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top