C# GRID Radio Buttons

Hello:

Using C#

I've a little problem with a grid and radio. I've a grid with 3 columns. One of these columns has 2 Radiobutton (in a group). The last column has a button (Submit)
I bind the grid in C# code behind (including textbox, label and radio button).
Now the problem is I bind the grid and depends what line, the radio will be selected. So it will checked.
The grid fill when the page load!!

But after I bind the grid, I want to select any RADIO in any row and change the selection.
I tried to use IspostBack, but I can't use it because everytime I selected the radiobutton the page reload.
So if I'll change the radiobutton, the page reload, fill the grid again and I lost the selection, that the problem I've with ispostback

So in little words what I need is: I need to change the "checked" radiobutton WITHOUT reload the page.
Maybe using javascript onlick.
But the problem with this solution is: I can't use onlick in asp:radiobutton, because is not supported.

Please if anyone can help, I will really appreciate it!

Thanks
NIKO
LVL 5
nkoriginalAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

monarch_ilhanCommented:
I think your radiobuttons autopostback property set to true. change it to false.
and on click event your button inside gridview, cast sender object to button and get parent.parent for reeaching gridviewrow

private Button1_Click(object sender, EventArgs e)
{
 Button btn=(Button)sender;
 GrivewRow row=(GridViewRow)btn.Parent.Parent;
 RadioButton rd1=(RadioButton)row.FindControl("RadioButtonControlName1");
 RadioButton rd2=(RadioButton)row.FindControl("RadioButtonControlName2");
if(rd1.Checked)
{
 //Do your reolad here
}
else if(rd2.Checked)
{
 //Do your reolad here
}
 
 
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nkoriginalAuthor Commented:
Hello Monarch:

Thank you for your reply.
I tried the code you send me but nothing happened.

the problem is when I load the page, the grid fill all fields. (textbox, radiobutton).
I when the I bind the radio, I send by code behind radiobutton.checked = true.
So the radiobutton will be checked in the GridView1_RowDataBound.
After all this, the user wants to change that status in the radiobutton, but nothing happen because by default the radio is checked in one value, maybe I will need a java script code?

Thank you
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.