hello,
i have a win application which im doing using C# and .NET in Visual Studio 2010
i have a data grid to which im binding some data from the database. i also have two radio buttons to which im binding distinct values of a particular column from the same database table.
after loading the table, i make some changes to the radio button text,it should automatically update those values in the datagrid view also in that particular column.
please let me know of the code to implement this functionality

string select= "select * from flowdata..data6_checklistlayouts where fk_ecytypes=269"
dataset ds=objAccess.fetchfromDB(select);
datagridview1.datasource=ds.tables[0];
string radiobtn="select distinct layoutid from flowdata..data6_checklistlayouts where layoutid lik eadditional%"
dataset ds1=objAccess.fetchfromDB(radiobtn);
int i=0;
for(i=o;i<ds1.tables[0].rows[0].count;i++)
{
string[] radiobtnval=convert.tostring(ds1.tables[0]);
}
RadioTextBox1.text=radiobtnval[0];
RadioTextBox2.text=radiobtnval[1];
RadioTextBox2.text=radiobtnval[2];

Im not sure bout he queries but radiobtn query fetches 3 values and puts it in the text boxes

when i make changes in radio text boxes it has to change in datagirdview1 for layout id

That loop is not ok. I dont even know how the varible "radiobtnval" is accessable outside of the loop, because you initialize it inside of the loop. And one more thing. Every time the code goes throught the loop oversides the array, so it will alway be filled with only the data on the last loop.

Lets repair this loop to:

1.This is when you want to loop trought all the rows:

List<string> list = new List<string();
for(i=o;i<ds1.Tables[0].Rows.Count;i++)
     list.Add(ds.Tables[0].Rows[i]["columnName"].ToString();

RadioTextBox1.text=list[0];
RadioTextBox2.text=list[1];
RadioTextBox2.text=list[2];
This article has been dead for over six months. Start a new discussion instead.