Sorting in datagrid

I have around 1000 records displayed in a datagrid. I am using a textbox to select a particular record i.e when I enter 5 in the textbox only the 5th record must be displayed.How do I do this.Can You suggest a good programming technique?

Comments

  • [b][red]This message was edited by patrik66 at 2004-2-2 2:39:51[/red][/b][hr]
    : I have around 1000 records displayed in a datagrid. I am using a textbox to select a particular record i.e when I enter 5 in the textbox only the 5th record must be displayed.How do I do this.Can You suggest a good programming technique?
    :

    Hi,

    If you are using SQL Server you can try something
    like this

    select Top 1 * from crap where crapid =
    (
    select Max(crapid) crapid from crap where crapid in
    (
    select Top 5 crapid from crap
    )
    )

    or you can filter the data with a rowfilter
    like this

    DataSet ds = new DataSet();
    sqlDataAdapter1.Fill(ds);
    DataView dv = ds.Tables[0].DefaultView;
    dv.RowFilter = "crapid = 5";
    dv.RowStateFilter = DataViewRowState.CurrentRows;
    DataGrid1.DataSource = dv;
    DataGrid1.DataBind();

    Note that this will not work if you set the datasource in
    the propertydesigner for the datagrid, and I do not know why.

    // Patrik





Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion