How do you save a dynamic datagrid to viewstate?

B

Burak Gunay

Hello,

I have a datagrid on my aspx page without any column definitions.

<asp:datagrid id="dtgValues" style="Z-INDEX: 101; LEFT: 2px; POSITION:
relative" Runat="server" PageSize="10" AutoGenerateColumns="False">

I create the columns and the data dynamically in the code behind
depending on which table the user selected.

When I postback the page, I load the grid again.

If you just use regular paging, and bind the whole dataset to the
datagrid, then paging works.

But when i try to use custom paging i run into problems.

on postback page_load, I load the data again by calling FillGrid()
function
, but then when the PageIndexChanged event gets executed,

Private Sub dtgValues_PageIndexChanged( source , e )
' Set the CurrentPageIndex before binding the grid
dtgValues.CurrentPageIndex = e.NewPageIndex
FillGrid()
End Sub

I end up with two datagrids next to each other.

Is there a way around this?

How can I save the datagrid in viewstate and load it again on the
postback?

Thanks,

Burak
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top