954,510 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

DataGridView and Radio Text Box

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

sushanth08
Newbie Poster
14 posts since Apr 2011
Reputation Points: 10
Solved Threads: 0
 

Hi, would you mind showing us the code you got there - would be faster to salve the issue. Thx in advance.

Mitja Bonca
Nearly a Posting Maven
2,485 posts since May 2009
Reputation Points: 641
Solved Threads: 474
 
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

sushanth08
Newbie Poster
14 posts since Apr 2011
Reputation Points: 10
Solved Threads: 0
 

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

sushanth08
Newbie Poster
14 posts since Apr 2011
Reputation Points: 10
Solved Threads: 0
 

datagridview1 has a column as layout id]
thanks in advance

sushanth08
Newbie Poster
14 posts since Apr 2011
Reputation Points: 10
Solved Threads: 0
 

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];
Mitja Bonca
Nearly a Posting Maven
2,485 posts since May 2009
Reputation Points: 641
Solved Threads: 474
 

Or would you like to get only values from one row? From 1st row (you stated row[0])?

Mitja Bonca
Nearly a Posting Maven
2,485 posts since May 2009
Reputation Points: 641
Solved Threads: 474
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: