none
is dvfill.RowFilter = null; required before filltering RRS feed

  • Question

  • Dear All

    DataTable dtfill = (DataTable)Session["keydtfill"];
    DataView dvfill = dtfill .DefaultView;
    dvfill.RowFilter = null;
    dvfill.RowFilter = "Visible='true'";
    grdfill.DataSource = dvfill.DefaultView;
    grdfill.DataBind();

     

    In above code is this line required dvfill.RowFilter = null; there is no if condition in between these lines.

     

    yours sincerely

    Wednesday, May 9, 2012 7:51 AM

Answers

  • I would avoid it in C#

    Rowfilter is a string so you are setting the reference to null and I guess you get an error on that. In my perception is better.

    dvFill.Rowfilter = ""; or if you wants equivalents like string.Empty

    VB and C# have in this significant different behavior. 

    In VB (and this forum is for all program languages which use DataSets so persons are watching this) 

    dvFill.Rowfilter = Nothing means the same as dvFill.RowFilter = "" because = nothing is default "" and Is Nothing means the same as C# = null.

     


    Success
    Cor



    • Edited by Cor Ligthert Wednesday, May 9, 2012 9:29 AM
    • Marked as answer by rajemessage Wednesday, May 9, 2012 12:51 PM
    Wednesday, May 9, 2012 9:29 AM

All replies

  • Hi,

    no, it is not needed. By default the value is an empty string.

    DataTable dtfill = (DataTable)Session["keydtfill"];
    dtfill.DefaultView.RowFilter = "Visible='true'";
    grdfill.DataSource = dvfill.DefaultView;
    grdfill.DataBind();


    Regards, Nico

    Wednesday, May 9, 2012 7:58 AM
  • I would avoid it in C#

    Rowfilter is a string so you are setting the reference to null and I guess you get an error on that. In my perception is better.

    dvFill.Rowfilter = ""; or if you wants equivalents like string.Empty

    VB and C# have in this significant different behavior. 

    In VB (and this forum is for all program languages which use DataSets so persons are watching this) 

    dvFill.Rowfilter = Nothing means the same as dvFill.RowFilter = "" because = nothing is default "" and Is Nothing means the same as C# = null.

     


    Success
    Cor



    • Edited by Cor Ligthert Wednesday, May 9, 2012 9:29 AM
    • Marked as answer by rajemessage Wednesday, May 9, 2012 12:51 PM
    Wednesday, May 9, 2012 9:29 AM