Dataset is one of those controls which programmers use most of the time for binding data to any of the Data Binding Control. When you fetch data from SQL Server in Dataset, then you can edit the fetched data before binding it to any of the Data Binding control. I have already discussed the same topic for Type Dataset over here. Using this approach your actual data in the Database will not change but the data which will be shown to user in browser.
- Before editing data in DataSet, you need to have data in a DataSet instance. Using following code, I fetched all the data from [abc] Table into DataSet instance ds.
SqlConnection con = new SqlConnection();
con.ConnectionString = @"Provide your own connection string here";
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "select * from [abc]";
cmd.Connection = con;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
- In the above image, I want to change the value for Address column ( [Eadd] – column name or 2 index) in 2nd row ( i.e index 1), then I can do so using any the following code.
ds.Tables.Rows["Eadd"] = "New Value"; //Eadd is the actual column name of Address column in Database
ds.Tables.Rows = "New Value";
- Here is the output in Browser after using any of the above statement for editing data in DataSet.
Incoming search terms:
- how to edit the details in asp net (1)