3 Answers, 1 is accepted
0
peter
Top achievements
Rank 1
answered on 09 Dec 2008, 07:21 PM
Derek
Perhaps you could share how you did this with me ? A small code sample will suffice.
Much appreciated
Hans
Perhaps you could share how you did this with me ? A small code sample will suffice.
Much appreciated
Hans
0
Shinu
Top achievements
Rank 2
answered on 10 Dec 2008, 04:55 AM
Hi Peter,
You can place the RadioButtonList in the FormTemplate and bind it in the code behind as shown below.
ASPX:
C#:
Thanks
Shinu
You can place the RadioButtonList in the FormTemplate and bind it in the code behind as shown below.
ASPX:
| <FormTemplate> |
| <asp:RadioButtonList ID="RadioButtonList1" runat="server"> |
| </asp:RadioButtonList> |
| </FormTemplate> |
C#:
| protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) |
| { |
| if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode)) |
| { |
| GridEditableItem edititem = (GridEditableItem)e.Item; |
| RadioButtonList radbtnlist = (RadioButtonList)edititem.FindControl("RadioButtonList1"); |
| Hashtable mycountries = new Hashtable(); |
| mycountries.Add("N", "Norway"); |
| mycountries.Add("S", "Sweden"); |
| mycountries.Add("F", "France"); |
| mycountries.Add("I", "Italy"); |
| radbtnlist.DataSource = mycountries; |
| radbtnlist.DataValueField = "Key"; |
| radbtnlist.DataTextField = "Value"; |
| radbtnlist.DataBind(); |
| } |
| } |
Thanks
Shinu
0
Roger
Top achievements
Rank 1
answered on 12 Mar 2009, 06:49 AM
Hi Shinu,
that piece of information on loading a radiobuttonlist was great & helped me greatly but I had problems accessing the radiobuttonlist as it wasn't bound to the original data.
So for anyone out there that has the same problem use the following code :
that piece of information on loading a radiobuttonlist was great & helped me greatly but I had problems accessing the radiobuttonlist as it wasn't bound to the original data.
So for anyone out there that has the same problem use the following code :
Dim rb As RadioButtonList = CType(editedItem.FindControl("RadioButtonList1"), RadioButtonList)
from the RadGrid_InsertCommand or RadGrid_EditCommand event.
Then use the rb.SelectedValue property to get the result of the RadioButtonList.
Note: if no radiobuttons are selected the resultant value will be an empty string (the normal non-select is -1 in a form) so check for the empty string before getting the value .
Regards