Hi there,

I'm quite new to ASP.NET development so i don't know what's the best way to do this...
I want to list some data in several rows and have a column with a checkbox or radiobutton that allows the user to select a row; Then I should get a value like an ID from that selected row and after a button click send that info to another page (or same page) but changing the displayed data based on the choice made before. Is that possible w/ datagridview or datalist? I mean without postbacks...

6 Years
Discussion Span
Last Post by Akash Saikia

How do I generate a column with that kind of controls and add it to the data to be displayed?


Little bit i get what you want to achieve,but please explain properly in detail,exactly what should happen.
This will help me.


I have an XML string and I bind it to DataGridView and it shows correctly the data in a table; I would like to have a column with some kind of control such as a radio button or whatever so that the user could select a row. Then I would pick, probably using JavaSrcipt, some value associated to that row and assync send it to the server-side, then I would present the user with a new interface based on the row selected before...
I hope i was clear; English is not my first language.. ;)

Thank you for your time.


:D :D ;)
Yes , it is crystal clear now.
1) Put a boundField into it.
2) Convert it into Template
3) Goto template editing mode and remove everything given inside the ItemTemplate,and put a radio button or Check box there.

4) To get the current selected row and values in that row,you must have fired the selected index changed event any how as per my knowledge.
----- Use Ajax update panel instead. -----

5) so again bound your grid view with select button or something,and apply some css to hide it,so that the normal select button is not visible.

6) Now in the row_databound event of your gridview write some code like this

protected void urgrid_RowDataBound(object sender, GridViewRowEventArgs e)
        if (e.Row.RowType == DataControlRowType.DataRow)
            e.Row.Cells[0].Attributes["onmouseover"] = "if(this.style.backgroundColor!='silver'){this.style.backgroundColor='#E2E2E2';}this.style.cursor='hand';";
            e.Row.Cells[0].Attributes["onmouseout"] = "if(this.style.backgroundColor!='silver'){this.style.backgroundColor='white';}";
            e.Row.Cells[0].Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(this.urgrid, "Select$" + e.Row.RowIndex);

7) the above given code will provide you to have a clickable row interface without having your select button to be clicked. When you click any row on first cell,it will fire your grid's selected index changed even and this is what we want so that we can get the selected row.
--I have considered that you have that clickable radio button or checkbox in your first column. Else change that Cells value.

8) Now in the selected index changed event,write whatever you wanted to achieve.

I hope it is clear :D

Edited by Akash Saikia: n/a

Votes + Comments

Good Mood :)
I'll try it out when I can, maybe in the next couple of hours. I'll let you know how it worked for me.
Thank's again for your time. Much appreciated.



Hello Akash Saikia,

Came back to give you some feedback...
Well, I sorted it out thanks to some of your instructions. Thank you so much.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.