Re: Add sorting to SQLDataAdapter at runtime. How?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: David Hearn (david.hearn_at_stagparkway.com)
Date: 06/17/04


Date: Thu, 17 Jun 2004 11:01:14 -0400

Bill,

Thanks for the reply. Using the DataView is a great idea! I will give it a
shot.

Thanks again!

David

"William Ryan eMVP" <dotnetguru@comcast.nospam.net> wrote in message
news:epe%23SiHVEHA.1652@TK2MSFTNGP09.phx.gbl...
>
>
>
> "David Hearn" <david.hearn@stagparkway.com> wrote in message
> news:eLJF%23THVEHA.716@TK2MSFTNGP11.phx.gbl...
> > I have a SQLDataAdapter that I have configured.
> Remember that the Adapter only moves data around, it has no bearing on the
> sort order for instance. Indirectly its command properties can do this
for
> you, but there are better objects
> Since I want to tie this to
> > a DataGrid and add sorting to the datagrid, I do not want to configure
the
> > adapter with sorting. I want to be able to add the sorting at runtime
> > depending on the column that the user clicked on the datagrid. I am
> probably
> > missing something very simple here. Below is the code that I am using to
> > fill my datagrid.
> >
>
> Create a DataView and bind to it (DataGrid.Datasource = DataView) and you
> can call the sort method of the view
> http://www.knowdotnet.com/articles/dataviewsort.html You can also click
on
> the column header to accomplish this but if you bind to a view, you can do
a
> lot with filtering and sorting and specifiy multiple sort conditions.
>
> Remember since you are in ASP.NET to call the sort before the post back is
> finished. A web datagrid iss just a HTML table so the page needs to be
> reconstructed to accomplish this, which is what occurs in the post back.
>
> Also, Particularly since you are using a web app, DON't use dynamic sql
> http://www.knowdotnet.com/articles/dynamisql.html
>
> HTH,
>
> Bill
> > Thanks in advance!
> >
> > sqlMfgNumber.SelectCommand.Parameters(0).Value = "%" &
> > txtSearchFor.Text.Trim & "%"
> >
> > sqlMfgNumber.SelectCommand.Parameters(1).Value = strOmittedNumber
> >
> > sqlMfgNumber.Fill(DsMfgNumberSearch1)
> >
> > If DsMfgNumberSearch1.Tables(0).Rows.Count > 0 Then
> >
> > lblError.Visible = False
> >
> > Datagrid1.DataSource = DsMfgNumberSearch1
> >
> > Datagrid1.DataBind()
> >
> > Else
> >
> > lblError.Visible = True
> >
> > End If
> >
> >
> >
> >
>
> --
>
> W.G. Ryan, eMVP
>
> http://forums.devbuzz.com/
> http://www.knowdotnet.com/williamryan.html
> http://www.msmvps.com/WilliamRyan/
>
>



Relevant Pages

  • RE: Datagrid paging I lose my sort
    ... you've also provide paging and sorting ... function for the datagrid. ... currently you found that after sorting ... So when we first make a sort operation, ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: ASP DataGrid Sorting
    ... DataViews for sorting. ... Certainly you could sort, ... > page using the ASP DataGrid. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: ASP DataGrid Sorting
    ... DataViews for sorting. ... Certainly you could sort, ... > page using the ASP DataGrid. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Add sorting to SQLDataAdapter at runtime. How?
    ... Remember that the Adapter only moves data around, it has no bearing on the ... sort order for instance. ... > a DataGrid and add sorting to the datagrid, I do not want to configure the ... > adapter with sorting. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: A Fast sorting algorithm for almost sorted data
    ... far my compressor has potential but is nowhere near ready. ... It does however make heavy use of sorting. ... which I am currently calling Run sort. ... entire selected run can be added to the sorted output array. ...
    (comp.compression)