[Solved] Find a vaule from columns of a dataset asp.net


I guess that is a DataTable inside a DataSet. First you need to query if the id is in the DataTable:

var dataTable = dataSet.Tables[0]; //For this example I'm just getting the first DataTable of the DataSet, but it could be other.
var id = 1;
var value = "football";

//Any(...) will return true if any record matches the expression. In this case, the expression is if a Id Field of the row is equals to the provided id
var contained = dataTable.AsEnumerable().Any(x =>x.Field<int>("Id") == id);

Then, if it’s not there, add a new row:

if(!contained)
{
    var row = dataTable.NewRow();

    row["Id"] = id;
    row["Value"] = value;

    dataTable.Rows.Add(row);
}

Hope it helps

solved Find a vaule from columns of a dataset asp.net