in

ASP.NET Weblogs

Datagrid Girl

Marcie, ASP.NET Datagrid Blogger Girl

August 2005 - Posts

  • Sorting with Datagrid ViewState disabled

    I've talked in the past about sorting a Datagrid without ViewState.  The key to getting this to work is calling .DataBind() on the DataGrid during Page_Load in order to wire up the SortCommand event.  I wanted to clarify something though, the .DataBind() doesn't have to be to the *real* .DataSource of the Datagrid, it can just be a dummy value.  Like so:

    Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
       dgReport.DataSource = New DataTable
       dgReport.DataBind()
    'bind to dummy datasource to wire up SortCommand event (ViewState is disabled)
    End Sub

    Private Sub dgReport_SortCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles dgReport.SortCommand
       ...
       BindData() 'bind to *real* datasource
    End Sub

    Marcie

  • showModalDialog and postbacks in ASP.NET

    I learned something new today that my coworker Dennis spent several agonizing hours trying to solve.  He was using window.showModalDialog to open a modal window on the client from Javascript, but whenever that page posted back, it would spawn off a new window.  (A normal window.open worked fine, this was only a problem for modal windows).  Some searching turned up several people with the same problem, and the solution once found (here), was quite simple:  just include this line in the < HEAD > html of the modal window:

    <base target=_self>

    Hope this saves someone else some time!
    Marcie

More Posts