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

Capturing the PrimaryKey Field Value Dynamically, when even Checkbox Status is changed

1 Answer 61 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ranganath
Top achievements
Rank 1
Ranganath asked on 21 Jul 2008, 01:31 PM

Hi,

First let me explain the Code which I implemented:-

<telerik:RadGrid PageSize="3" AllowPaging="true" ID="rg_AddMainMenu" runat="server"

                                GridLines="Horizontal" Skin="Default" AllowAutomaticDeletes="True" OnNeedDataSource="rg_AddMainMenu_NeedDataSource"

                                Font-Strikeout="False" Font-Underline="False" OnInsertCommand="rg_AddMainMenu_InsertCommand"

……….">

                                <PagerStyle Mode="Slider" />

                                <MasterTableView AutoGenerateColumns="false" DataKeyNames="MAINMENUID" EditMode="EditForms"

                                    CommandItemDisplay="TopAndBottom">

                                    <RowIndicatorColumn Visible="False">

                                        <HeaderStyle Width="20px"></HeaderStyle>

                                    </RowIndicatorColumn>

                                    <ExpandCollapseColumn Visible="False" Resizable="False">

                                        <HeaderStyle Width="20px"></HeaderStyle>

                                    </ExpandCollapseColumn>

                                    <Columns>

                                        <telerik:GridEditCommandColumn>

                                        </telerik:GridEditCommandColumn>

                                        <telerik:GridBoundColumn ReadOnly="true" Visible="false" HeaderText="MainMenu ID"

                                            DataField="MAINMENUID" UniqueName="MAINMENUID" />

                                        <telerik:GridBoundColumn ReadOnly="false" HeaderText="MainMenu Name" DataField="MAINMENUNAME"

                                            UniqueName="MAINMENUNAME" />

                                        <telerik:GridBoundColumn ReadOnly="false" HeaderText="Description" DataField="MAINMENUDESC"

                                            UniqueName="MAINMENUDESC" />

                               

                                        <telerik:GridTemplateColumn HeaderText="Active" DataField="DELETEDFLAG" UniqueName="">

                                            <ItemTemplate>

                                                <asp:CheckBox runat="server" OnCheckedChanged="chkMenustatus_CheckedChanged" ID="chkMenustatus" Checked='<%# Bind("IsActive") %>'

                                        AutoPostBack="true"  />

                                            </ItemTemplate>

                                        </telerik:GridTemplateColumn>

                                    </Columns>

                                    <EditFormSettings EditFormType="Template">

                                        <EditColumn UniqueName="EditCommandColumn1">

                                        </EditColumn>

                                        <FormTemplate>

                                            <table id="Table2" cellspacing="2" cellpadding="1" class="TableBackGround" width="100%"

                                                border="1" rules="none" style="border-collapse: collapse">

                                                <tr>

                                                    <td align="center">

                                                        <table id="Table3" cellspacing="1" class="TableBackGround" cellpadding="1" border="0">

So On….

                                    </EditFormSettings>

                                </MasterTableView>

                            </telerik:RadGrid>

C#:-

protected void chkMenustatus_CheckedChanged(object sender, EventArgs e)

{

//Actually I want to capture the ID of selected Checked Row

}

Q:-

I had 4 Columns named by MenuID, MName, Desc, IsActive(Menu Stagtus)

When ever I will change the checked status of the CheckBox, I have to capture the MenuID and change Status of Menu.

So finally I want to capture the MenuID when I change CheckBox status?

Please help me in this regards.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 22 Jul 2008, 06:47 AM
Hello Ranganath,

Try out the following code snippet  to get the desired result.
cs:
protected void chkMenustatus_CheckedChanged(object sender, EventArgs e) 
    { 
        CheckBox chkbx = (CheckBox)sender; 
       GridDataItem item = (GridDataItem)chkbx.NamingContainer; 
       string strtxt = item.GetDataKeyValue("MAINMENUID").ToString();  
         
    } 

Thanks
Princy.

Tags
Grid
Asked by
Ranganath
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or