Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all experts,

i have declared one dataset (ds). this dataset will get values from my database and in dataset has 1 col called "Magin".
In my form, i created 1 text box called "Magin".
when i input 4 in Magin Text box, i want all magin value in dataset will update to 4 (based on magin text box value).
Is it possible that i can update values in dataset based on the value on my text box?

Note:
My dataset can store from 100 rows up.please avoid to use loop

Thanks

TONY
Posted

Hi Tony,

even if it sounds like a homework, try this. Use Expression property of a column to update it to a desired value.

private void button1_Click(object sender, EventArgs e)
{
    // create a new ds with a table and a column
    DataSet ds = new DataSet();

    ds.Tables.Add("Table1");

    ds.Tables[0].Columns.Add("Magin", typeof(int));

    // populate some test data
    for (int i = 0; i < 100; i++)
    {
        DataRow dr = ds.Tables[0].NewRow();

        dr[0] = i;

        ds.Tables[0].Rows.Add(dr);
    }

    // update the column to a value
    ds.Tables[0].Columns["Magin"].Expression = "4";
}



Keep in mind that string values should be quoted.

Cheers
 
Share this answer
 
VB
For I As Integer = 0 To DatasetName.Tables("TableName").Rows.Count - 1
    DatasetName.Tables("TableName").Rows(I).Item(0) = TextBox1.Text
Next
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900