This is a migrated thread and some comments may be shown as answers.

Radiobutton as edit command button in RadGrid

3 Answers 100 Views
Grid
This is a migrated thread and some comments may be shown as answers.
taeho
Top achievements
Rank 1
taeho asked on 05 Jan 2009, 11:10 PM
Hi there,

Happy new year for all!!!
How to use a radiobutton inside gridTemplateColumn as editcommand button?
When you check a radiobutton, the corresponding row should get changed to edit mode.

Thanks in advance,

Toby

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 06 Jan 2009, 03:50 AM
Hi Toby,

Try the following code snippet to achieve the desired scenario.

ASPX:
 <telerik:GridTemplateColumn UniqueName="TempCol"  HeaderText="TempCol"  > 
               <ItemTemplate> 
                   <asp:RadioButton ID="RadioButton1" runat="server" AutoPostBack="True" OnCheckedChanged="RadioButton1_CheckedChanged"   /> 
               </ItemTemplate> 
             </telerik:GridTemplateColumn> 

CS:
 protected void RadioButton1_CheckedChanged(object sender, EventArgs e) 
    { 
        RadioButton radbtn = (RadioButton)sender; 
        GridDataItem item = (GridDataItem)radbtn.NamingContainer; 
        item.Edit = true
        RadGrid1.MasterTableView.Rebind(); 
    } 


Thanks
Shinu.
0
Alejandro Resendiz
Top achievements
Rank 1
answered on 18 May 2010, 11:20 PM
hi shinu

how can i call javascript function
when radio button 1    checked changed
when radiobutton 
without postback
0
Shinu
Top achievements
Rank 2
answered on 19 May 2010, 06:49 AM
Hello Alejandro,

Try the following code snippet to attach "onclick" event to RadioButton and to pass the row index to the client event handler. You can then access corresponding row/item using the index passed.

C#:
  
 protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            RadioButton btn = (RadioButton)item.FindControl("RadioButton1"); 
            btn.Attributes.Add("onclick""CheckedChanged('"+item.ItemIndex+"');"); 
        } 
    } 

Java Script:
<script type="text/javascript"
    function CheckedChanged(index) { 
        alert(index); 
    } 
</script> 

Regards,
Shinu.


Tags
Grid
Asked by
taeho
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Alejandro Resendiz
Top achievements
Rank 1
Share this question
or