Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a datagrid that is bound to a resultset. I have a checkbox and the column returned from the resultset in the grid.

 

The problem I'm having is this. The result set is returning 50 records, which causes the grid to build beyond the page and you have to scroll the page down to see the entire grid.

 

What I would like to do is something like the dataList allows you to do. You can set the RepeatColumn attribute and the RepeatDirection to allow the list to build horizontally and look better. Is there a way to accomplish this with the dataGrid ? Or is the solution putting a scroll bar on the datagrid and set it's height and width and use the scroll bar within the grid to scroll.

 

Does anyone have any insight?

 

Thanks in advance!

Rick

Posted (edited)

paging is correct option.

But if you want a scroll bar

well here is an option

 

For vertical scrolling within a 600X100 pixel panel:

 

<asp:panel id="pnlList" Width="600px" Height = "100px" style="overflow:auto" runat="server" >

 

...Place datagrid or datalist here

 

</asp:panel>

 

For Horizontal scrolling:

 

<asp:panel id="pnlList" Width="600px" Height = "100px" style="overflow:scroll" runat="server" >

 

...Place datagrid or datalist here

 

</asp:panel>

[edit]disabled smilies[/edit]

Edited by Robby
Posted

I've added paging to the datagrid using a method I found on the internet. I'm not sure it is the correct way to do this however. Here is the code I use to load the grid and the corresponding code to allow the paging.

 

OleDbConnection.Open()

OleDbDataAdapter.Fill(dsSkillSet,"skillset")

Session.Add("ds",dsSkillSet)

DataGrid.DataBind()

 

Here is the PageIndexChanged event

 

DataGrid.CurrentPageIndex = e.NewPageIndex

dsSkillSet = Session("ds")

DataGrid.DataBind()

 

The problem I'm having is that if I select records on the first page, and then select the second page, I lose all those records selected on the first page. Should I create another session object to track all the selected items? How do I loop through the items on a specific page, or do I need to loop through the entire grid contents?

 

Is the session object the proper way to work with this type of paging?

 

I'm still new to this, so please feel free to correct my thinking or ideas.

 

thanks in advance.

Rick

Posted

If I don't do a DataGrid.DataBind(), then the paging won't change when you click on each page number to scroll through the list. You need to rebind the grid to get the items to change.

 

I'm wondering if in this event, I need to do some sort of looping and adding selected items to an array or something?

 

Any ideas?

  • 2 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...