"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Showing posts with label dataview. Show all posts
Showing posts with label dataview. Show all posts

Wednesday, January 30, 2013

Remove Duplicate Row from datatable in c#

As i was also unaware of this feature until i read as answer in fourms.asp.net (link). Previously i was achieved by using lambda expression.Now no need to those just one line code :)


DataTable dt = new DataTable
        {
            Columns ={
                {"Myid",typeof(int)},
                {"Name"},
                {"Address"}
                }
        };
        dt.Rows.Add(1, "Arun Aravind", "Kollam");
        dt.Rows.Add(1, "Arun Aravind", "Kollam");
        dt.Rows.Add(2, "Arun Aravind", "Kollam");
        dt.Rows.Add(2, "Arun Aravind", "Kollam");
        dt.Rows.Add(3, "Arun Aravind", "Kollam");

        dt = dt.DefaultView.ToTable(false, "Address", "Name", "Myid");

Output




If u had any trouble just ask, Happy to help u :)
Stay Tune... Have a nice day... 'N happy Coding :)

Tuesday, January 15, 2013

join two DataTables where both having a common column

Join two DataTables where both having a common column


      DataTable dt1 = new DataTable("Table1");

        DataTable dt2 = new DataTable("Table2");

        DataSet ds = new DataSet("DataSet");


Sunday, November 11, 2012

Fetch data between two dates in dataview rowfilter

 Fetch data between two dates in dataview rowfilter
DateTime from = Convert.ToDateTime(txtFrom.Text);
DateTime to = Convert.ToDateTime(txtTo.Text);
string dateFilterString = "CreatedOnFilter >= #" + from + "# AND CreatedOnFilter <= #" + to + "#";



If u had any trouble just ask, Happy to help u :)
 Stay Tune...
 Have a nice day... 'N happy Coding :)