By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,786 Members | 2,241 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,786 IT Pros & Developers. It's quick & easy.

Scrollable datagrid: dynamic paging

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a

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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.