Saturday, October 16, 2010

How to use where condition in Dataset

Question: where condition is possible only with SQL?
Ans:  No, we can use where condition in .NET Datset also

The main requirement is  delete a row when row text is "Invalid" from a DropDownList
Sol:  i need to use where condition in  a dataset, is possible only by using Select() method of dataset

private Dataset GetstudentData()
        string query=//write your query as per your requirement
        sqldataadapter da=new sqldataadapter(query,con);
       Dataset ds=new Dataset()    
       DataRow []row1 = ds.Tables[0].Select(("Text='Invalid'"));//Where condition goes here // i need to delete                      row which contains  invalid text
        return ds;

No comments:

Post a Comment