473,396 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Scrollable datagrid: dynamic paging

RJN
Hi

Sorry for posting again.

I have a datagrid which is put inside a div tag to make it scrollable. I
need to page the datagrid. The page numbers appear at the bottom of the
datagrid and has to be scrolled down completely to see the page number
links. The page number should always be visible outside the scroll bar.
Basically I want to create the paging links dynamically and on click of
this it should fire PageIndexChanged event.

The following link has an example of scrollable/sortable datagrid. I'm
trying to paging in the similar way.
http://www.extremeexperts.com/Net/Ar...ridwithSorting
.aspx

I introduce a table below the datagrid and this table will have all the
paging links.

In the ItemCreated event of the datagrid, I get the control collection
of the paging links and add it to the table.

If e.Item.ItemType = ListItemType.Pager Then
Dim i As Int16
For i = 0 To e.Item.Controls(0).Controls.Count - 1
--Create a new link button
--Get the e.Item.Controls(0).Controls(i) and assign
its properties to link button
--Add the link button to the table
Next
End if

Now I need to assign the events to the new paging links created. It
should fire PageIndexChanged event.

To do this , in the ItemDataBound event I add the
Page.GetPostBackClientHyperlink to the link button .

But in ItemDataBound I'm not able to execute the statements within the
below if condition.
If e.Item.ItemType = ListItemType.Pager

End if

This statement is not executed at all.

Any help is appreciated.

Regards

RJN


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #1
2 2557

Hi RJN,

Item_DataBound event will fire only if you do databinding in that datagrid.
If you send your code behind code, then it will be easier to find the issue.

--
Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com
"RJN" <rj*@yahoo.com> wrote in message
news:Ok**************@TK2MSFTNGP09.phx.gbl...
Hi

Sorry for posting again.

I have a datagrid which is put inside a div tag to make it scrollable. I
need to page the datagrid. The page numbers appear at the bottom of the
datagrid and has to be scrolled down completely to see the page number
links. The page number should always be visible outside the scroll bar.
Basically I want to create the paging links dynamically and on click of
this it should fire PageIndexChanged event.

The following link has an example of scrollable/sortable datagrid. I'm
trying to paging in the similar way.
http://www.extremeexperts.com/Net/Ar...ridwithSorting
aspx

I introduce a table below the datagrid and this table will have all the
paging links.

In the ItemCreated event of the datagrid, I get the control collection
of the paging links and add it to the table.

If e.Item.ItemType = ListItemType.Pager Then
Dim i As Int16
For i = 0 To e.Item.Controls(0).Controls.Count - 1
--Create a new link button
--Get the e.Item.Controls(0).Controls(i) and assign
its properties to link button
--Add the link button to the table
Next
End if

Now I need to assign the events to the new paging links created. It
should fire PageIndexChanged event.

To do this , in the ItemDataBound event I add the
Page.GetPostBackClientHyperlink to the link button .

But in ItemDataBound I'm not able to execute the statements within the
below if condition.
If e.Item.ItemType = ListItemType.Pager

End if

This statement is not executed at all.

Any help is appreciated.

Regards

RJN


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #2
RJN

Hi Sarvana

Thanks for your reply. We have followed the similar approach that you
have given in one of your articles. In the ItemCreated event we created
all the links and in the ItemDataBound event we attached the events for
these links.

In the .aspx we have a created a table "tblPage" for showing the page
number links.

This is the code in .aspx.vb page in the ItemCreated event.

If e.Item.ItemType = ListItemType.Pager Then
tblPage.Rows(0).Cells.Clear()
For ipage = 0 To e.Item.Controls(0).Controls.Count - 1
strType = e.Item.Controls(0).Controls(ipage).GetType.FullNam e
tblcell = New TableCell
Select Case strType
Case "System.Web.UI.LiteralControl"
Dim ltPage As New LiteralControl
ltPage.ID =
e.Item.Controls(0).Controls(ipage).ClientID
ltPage.Text = "&nbsp;"
tblcell.Controls.Add(ltPage)
Case "System.Web.UI.WebControls.Label"
Dim lblPage As New Label
lblPage.CssClass = "MSPullDownContent"
lblPage.ID =
e.Item.Controls(0).Controls(ipage).ClientID
lblPage.Text =
CType(CType(e.Item.Controls(0).Controls(ipage), System.Web.UI.Control),
System.Web.UI.WebControls.Label).Text
tblcell.Controls.Add(lblPage)

Case "System.Web.UI.WebControls.DataGridLinkButton"
Dim lnkbutton As New LinkButton
Dim ctl As
System.Web.UI.WebControls.DataGridItem

lnkbutton.ID =
CType(e.Item.Controls(0).Controls(ipage),
System.Web.UI.Control).ClientID
lnkbutton.CommandArgument =
CType(CType(e.Item.Controls(0).Controls(ipage), System.Web.UI.Control),
System.Web.UI.WebControls.LinkButton).CommandArgum ent
lnkbutton.CommandName =
CType(CType(e.Item.Controls(0).Controls(ipage), System.Web.UI.Control),
System.Web.UI.WebControls.LinkButton).CommandName
lnkbutton.Text =
CType(CType(e.Item.Controls(0).Controls(ipage), System.Web.UI.Control),
System.Web.UI.WebControls.LinkButton).Text
lnkbutton.Style.Add("text-decoration", "none")
lnkbutton.Attributes.Item("onclick") =
Page.GetPostBackClientHyperlink(e.Item.Controls(0) .Controls(ipage),
lnkbutton.CommandArgument)
tblcell.Controls.Add(lnkbutton)
End Select
tblPage.Rows(0).Cells.Add(tblcell)
Next
--In the Item databound event:

If e.Item.ItemType = ListItemType.Pager Then
Dim ipage As Int16
Dim strType As String

For ipage = 0 To e.Item.Controls(0).Controls.Count - 1
strType =
e.Item.Controls(0).Controls(ipage).GetType.FullNam e
If strType =
"System.Web.UI.WebControls.DataGridLinkButton" Then
Dim lnkbutton As LinkButton
Dim oControl As LinkButton
oControl = CType(e.Item.Controls(0).Controls(ipage),
System.Web.UI.WebControls.LinkButton)
lnkbutton =
tblpage.Rows(0).Controls(ipage).Controls(0)
lnkbutton.Style.Add("text-decoration", "none")
lnkbutton.Attributes.Add("href",
Page.GetPostBackClientHyperlink(e.Item.Controls(0) .Controls(ipage), ""))
End If
Next
End If

The links are being created but events are not attached to them. Will
you be able to tell where we are doing wrong?

Regards

Rjn

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Clement | last post by:
I have an user control(Control1) that dynamically adds another user control(Control2). In Control2, I am displaying data in a datagrid which I enable paging and sorting. When I click on the page...
2
by: Ben | last post by:
Hi, I'd like to have a datagrid that has a dropdownlist in the pager control for setting the page size. I can get the control into the pager inside the datagrid itemcreated event by checking for...
0
by: RJN | last post by:
Hi I have a datagrid which is put inside a div tag to make it scrollable. I need to page the datagrid. The page numbers appear at the bottom of the datagrid and has to be scrolled down...
1
by: RJN | last post by:
Hi Sorry for posting again. I have a datagrid which is put inside a div tag to make it scrollable. I need to page the datagrid. The page numbers appear at the bottom of the datagrid and has...
6
by: Shawn | last post by:
Hi. I already have a datagrid where I'm using paging. I have a stored procedure that fills a temp table with 200-500 rows and then sends back 10 records at the time. When I go to page 2 the SP...
5
by: tshad | last post by:
Is there a way to carry data that I have already read from the datagrid from page to page? I am looking at my Datagrid that I page through and when the user says get the next page, I have to go...
6
by: coleenholley | last post by:
Hi All :-) I need to populate a table I created as a web form. Are there any links to show me how to do this? I CANNOT use a dtagrid for this, the table has to be laid out as follows: Header...
0
by: ashish.dwivedi1 | last post by:
Hi, I am building a ASP .NET composite control containing a datagrid during which I am finding a problem while paging of the grid. The problem is for example if I am having three pages to be...
0
by: rn5a | last post by:
In a shopping cart app, a user purchases 5 items on 31st March 2007. This is his 1st order. He places a 2nd order on 13th April in which he buys 8 items. Next he places his 3rd order on 16th April...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.