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

Help needed to get the checkbox column value

2 Answers 113 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sravanthi
Top achievements
Rank 1
sravanthi asked on 06 Jun 2011, 06:07 PM
Hi Everyone,

I needed help to solve the problem:
    My ISSUE is I had a Rad grid in which the columns are automatically generated
The grid code looks like this

<telerik:RadGrid ID="rgTSSearch" runat="server" Skin="Outlook" Width="97%" ShowStatusBar="True"
        AllowSorting="True" PageSize="10" GridLines="None" OnColumnCreated="rgTSSearch_ColumnCreated"
        OnItemCreated="rgTSSearch_ItemCreated" OnNeedDataSource="rgTSSearch_NeedDataSource"
        OnItemCommand="rgTSSearch_ItemCommand" OnUpdateCommand="rgTSSearch_UpdateCommand"
        OnCancelCommand="rgTSSearch_CancelCommand" OnInsertCommand="rgTSSearch_InsertCommand">
        <PagerStyle Mode="NextPrevAndNumeric" />
        <MasterTableView Width="100%" DataKeyNames="ID" CommandItemSettings-ShowAddNewRecordButton="false"  CommandItemDisplay="Top" HorizontalAlign="NotSet">
            <CommandItemTemplate>
                <asp:LinkButton ID="btnInitInsert" runat="server" CommandName="InitInsert"><img style="border:0px;vertical-align:middle;height:20px; width:20px;" alt="" src="../../App_Themes/add.png" />Add new TS</asp:LinkButton>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <asp:LinkButton ID="btnRebind" runat="server" CommandName="RebindGrid"><img style="border:0px;vertical-align:middle; height:20px; width:20px;" alt="" src="../../App_Themes/refresh.png" />Refresh</asp:LinkButton>
            </CommandItemTemplate>
            <Columns>
                <telerik:GridEditCommandColumn ButtonType="ImageButton" HeaderStyle-Width="10%" UniqueName="EditColumn" />
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>

In the automatic generated columns there are two bit datatype columns which are generated as a checkbox column.

Now when I edit a particular row how to set the check box in the edit form[External form] based on the value in the grid
I mean If the check box column in the grid is checked then the checkbox column in the External form should be checked .

I tried in different ways but nothing worked out .


So please help me......


Thanks In advance,
Sravz


2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 07 Jun 2011, 08:01 AM
Hello Sravanthi,

Give a try with the following approach to check the checkbox column in external form.

C#:
protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e)
{
   if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
    {
         GridEditFormItem editItem = (GridEditFormItem)e.Item;
         GridDataItem item = (GridDataItem)editItem.ParentItem;
         CheckBox chkbox1 = (CheckBox)item["GridCheckBoxColumn"].Controls[0];      
         UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
         CheckBox chkbox = (CheckBox)userControl.FindControl("CheckBox1");         
         chkbox.Checked = chkbox1.Checked;
      }
 }

Thanks,
Princy.
0
sravanthi
Top achievements
Rank 1
answered on 07 Jun 2011, 02:50 PM
Hi Princy,
Thanks for  the reply........
I think what I explained is not clear:The external form I was speaking is not the user control.It is just a form in the div tag.
when the user clicks on edit the selected row values should be present in the form for that I did it like this:

 protected void DisplayEditForm(GridDataItem selectedItem)
    {
       
        txtComments.Text = selectedItem["COMMENTS"].Text;
   }
for the text box this is working .But here I want to get the checkbox value and make the checkbox in the form to be checked or not checked based on that value...


Thanks,
Sravanthi
Tags
Grid
Asked by
sravanthi
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
sravanthi
Top achievements
Rank 1
Share this question
or