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

How to access value of column in Edit mode: Grid / Form Template Edit Form

5 Answers 701 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Winwizardy
Top achievements
Rank 1
Winwizardy asked on 20 Jun 2012, 04:11 AM
hi all,
i'm new to telerik. would appreciate if someone could help me here.
How can i access the value(exmple an ID) in column during the edit mode?
i need to use that ID to do another action. can somebody show me how i can get the value ?
here some of my my code(i will put more codes if its not enough)
aspx:
<MasterTableView CommandItemDisplay="TopAndBottom" DataSourceID="SqlDataSource1"
           DataKeyNames="ID">
           <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
           <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
           </RowIndicatorColumn>
           <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
           </ExpandCollapseColumn>
           <Columns>
               <telerik:GridEditCommandColumn>
               </telerik:GridEditCommandColumn>
               <telerik:GridBoundColumn UniqueName="ID" HeaderText="ID" DataField="ID" DataType="System.Int64"
                   FilterControlAltText="Filter ID column" ReadOnly="True" SortExpression="ID">
               </telerik:GridBoundColumn>
                     ...
                       ...
how can i access the value of ID in code behind?

thanks,

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Jun 2012, 04:19 AM
Hello,

Try the following code to access columns in edit mode.
C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
  if (e.Item is GridEditableItem && e.Item.IsInEditMode)
   {
      GridEditableItem item = (GridEditableItem)e.Item;
      TextBox txt = (TextBox)item["ID"].Controls[0];
      string value = txt.Text;
  }
}

Thanks,
Shinu.
0
Winwizardy
Top achievements
Rank 1
answered on 20 Jun 2012, 04:35 AM
hi, thanks for your reply,
may i asked, is there is a way for me to make this string value accessible to another function in the code behind?
like i was trying to use the value in this codes:
protected void cblSeatingArrangment_DataBound(object sender, EventArgs e)
        {
 
            //to access the checknboxlist in the telerik:          
            CheckBoxList cblsa = (CheckBoxList)sender;
            GridEditFormItem item = (GridEditFormItem)cblsa.NamingContainer;
            CheckBoxList cbl = (CheckBoxList)item.FindControl("cblSeatingArrangment");
 
 
 
            database d = new database(genericConstants.SVAR_DB_CONN_NAME);
            d.Query = "GetSeatingArrangementList_ByReservationID";
 
            d.InitDataReaderWithParams(
                new SqlParameter[] { new SqlParameter("@ReservationID", SqlDbType.BigInt) },
                new object[] { Int64.Parse(value) },
                                CommandType.StoredProcedure);
 
            while (d.findMoreRows())
            {
 
                foreach (ListItem i in cbl.Items)
                {
                    if (i.Value == d.returnRow("ID").ToString())
                        i.Selected = true;
                }
            }
            d.CloseDataReader();
            d.Close();
 
        }

i try to make the variable as global but doesn't seem to work. am i missing something here?
can you help me here again, please
thanks

0
Shinu
Top achievements
Rank 2
answered on 21 Jun 2012, 05:17 AM
Hi,

I guess you need the BoundColumn value in the CheckBoxList DataBound event while editing an item. Please check the following code snippet to get the BoundColumn value in the CheckBoxList DataBound event.

C#:
protected void cblSeatingArrangment_DataBound(object sender, EventArgs e)
{
    CheckBoxList chklst = (CheckBoxList)sender;
    GridEditableItem eitem = (GridEditableItem)chklst.NamingContainer;
    TextBox textbox = (TextBox)eitem["ID"].Controls[0];
    string value =textbox.Text;
}
Please provide your complete aspx code if it doesn't help.

Thanks,
Shinu.
0
Winwizardy
Top achievements
Rank 1
answered on 21 Jun 2012, 06:01 AM
thanks shinu for your reply.
i try your code but i got this error:

Specified argument was out of the range of valid values.
Parameter name: index

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index
Source Error: 
Line 34:             CheckBoxList chklst = (CheckBoxList)sender;
Line 35:             GridEditableItem eitem = (GridEditableItem)chklst.NamingContainer;
Line 36:             TextBox textbox = (TextBox)eitem["ID"].Controls[0];
Line 37:             string value = textbox.Text;
Line 38: 



i try to simplify my codes here for you
Aspx:
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:Label ID="test" runat="server" Text="Label"></asp:Label>
    <br />
 
                <table width="100%" cellpadding="0" cellspacing="0" border="0" align="right">
                    <tr>
                        <td class="bar_breadcrumb_left" width="17px" height="30px">
                              
                        </td>
                        <td class="bar_breadcrumb_center" height="30px">
                            <%--Home > Hotel > Hotel Reservation--%>
                            <uc1:uc_eventName ID="uc_eventName1" runat="server" />
                        </td>
                        <td class="bar_breadcrumb_right" width="13px" height="30px">
                              
                        </td>
                    </tr>
                </table> <br />
                <table width="100%" cellpadding="0" cellspacing="0" border="0" align="right">
                    <tr>
                        <td class="bar_title_left" width="21px">
                              
                        </td>
                        <td class="bar_title_center" align="right">
                            <font class="title"><font color="#1044aa">VIEW</font> ENQUIRY LIST</font>
                        </td>
                        <td class="bar_title_right" width="13px">
                              
                        </td>
                    </tr>
                </table>
                <table border="0" align="center" class="form_content">
                    <tr>
                        <td align="center">
                            <!-- BOX -->
                            <table border="0" cellpadding="2" cellspacing="2" bgcolor="white" width="400px">
                                <tr>
                                    <td align="left" valign="top" width="130px">
                                        Venue
                                    </td>
                                    <td align="left" valign="top">
                                        :
                                    </td>
                                    <td align="left" valign="top">
                                        <asp:DropDownList ID="ddlHotel" runat="server" DataSourceID="sdsHotelListFilter"
                                            DataTextField="HotelName" DataValueField="HotelID">
                                        </asp:DropDownList>
                                        <asp:SqlDataSource ID="sdsHotelListFilter" runat="server" ConnectionString="<%$ ConnectionStrings:EMS %>"
                                            SelectCommand="GetHotelListFilter_ByUserID" SelectCommandType="StoredProcedure">
                                            <SelectParameters>
                                                <asp:SessionParameter DefaultValue="0" Name="UserID" SessionField="_$USER_ID" Type="Int32" />
                                            </SelectParameters>
                                        </asp:SqlDataSource>
                                    </td>
                                </tr>
                                 
                                <tr>
                                    <td align="left" valign="top">
                                          
                                    </td>
                                    <td align="left" valign="top">
                                          
                                    </td>
                                    <td align="left" valign="top">
                                        <table border="0" width="50px" cellpadding="0" cellspacing="0">
                                            <tr>
                                                <td>
                                                    <asp:Button ID="btnSearch" runat="server" OnClick="btnSearch_Click" Text="Search" />
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
 
 
  <p id="divMsgs" runat="server">
                    <asp:Label ID="Label1" runat="server" EnableViewState="False" Font-Bold="True" ForeColor="#FF8080"></asp:Label>
                    <asp:Label ID="Label2" runat="server" EnableViewState="False" Font-Bold="True" ForeColor="#00C000"></asp:Label>
                </p>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            function RowDblClick(sender, eventArgs) {
                sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
            }
        </script>
    </telerik:RadCodeBlock>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="divMsgs" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
    <telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None" AllowPaging="True"
        PageSize="20" AllowSorting="True" AutoGenerateColumns="False" ShowStatusBar="True"
        AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True"
        DataSourceID="SqlDataSource1" OnItemDeleted="RadGrid1_ItemDeleted" OnItemInserted="RadGrid1_ItemInserted"
        OnItemUpdated="RadGrid1_ItemUpdated" OnItemCommand="RadGrid1_ItemCommand" OnPreRender="RadGrid1_PreRender"
        CellSpacing="0" Skin="Office2010Blue" OnItemDataBound="RadGrid1_ItemDataBound">
        <MasterTableView CommandItemDisplay="TopAndBottom" DataSourceID="SqlDataSource1"
            DataKeyNames="ID">
            <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
            <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
            </RowIndicatorColumn>
            <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
            </ExpandCollapseColumn>
            <Columns>
                <telerik:GridEditCommandColumn>
                </telerik:GridEditCommandColumn>
                <telerik:GridBoundColumn UniqueName="ID" HeaderText="ID" DataField="ID" DataType="System.Int64"
                    FilterControlAltText="Filter ID column" ReadOnly="True" SortExpression="ID">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="HostCompanyName" FilterControlAltText="Filter HostCompanyName column"
                    HeaderText="Company Name" SortExpression="HostCompanyName" UniqueName="HostCompanyName">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="HostName" FilterControlAltText="Filter HostName column"
                    HeaderText="Contact Person" SortExpression="HostName" UniqueName="HostName">
                </telerik:GridBoundColumn>               
                <telerik:GridBoundColumn UniqueName="column1" HeaderText="QuotationID" DataField="QuotationID"
                    FilterControlAltText="Filter column1 column" SortExpression="QuotationID" Visible="true">
                </telerik:GridBoundColumn>
            </Columns>
            <EditFormSettings EditFormType="Template">
                <EditColumn UniqueName="EditCommandColumn1" FilterControlAltText="Filter EditCommandColumn1 column">
                </EditColumn>
                <%-- start form--%>
                <FormTemplate>
                    <table id="Table2" cellspacing="2" cellpadding="1" width="100%" border="0" rules="none"
                        style="border-collapse: collapse; background: white;">
                        <tr class="EditFormHeader">
                            <td colspan="2" style="font-size: small">
                                <b>Client Enquiry</b>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <b>Client Info:</b>
                            </td>
                        </tr>
                        <tr>
                            <td valign="top">
                                <table id="Table3" cellspacing="1" cellpadding="1" width="300" border="0">
                                    <tr>
                                        <td>
                                        </td>
                                        <td>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Contact Person:
                                            <asp:RequiredFieldValidator ID="rfvLocationName" runat="server" ControlToValidate="txtName"
                                                Display="Dynamic" ErrorMessage=" Please enter Location Name" Text="*" ValidationGroup="vgEvent"></asp:RequiredFieldValidator>
                                        </td>
                                        <td>
                                            <asp:TextBox ID="txtName" runat="server" Width="200px" Text='<%# Bind("HostName") %>'>
                                            </asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Address:
                                            <asp:RequiredFieldValidator ID="rfvAddress" runat="server" ControlToValidate="txtAddress"
                                                Display="Dynamic" ErrorMessage=" Please enter Location Address" Text="*" ValidationGroup="vgEvent"></asp:RequiredFieldValidator>
                                        </td>
                                        <td>
                                            <asp:TextBox ID="txtAddress" Text='<%# Bind("Address") %>' runat="server" TextMode="MultiLine"
                                                Rows="5" Columns="40" TabIndex="5">
                                            </asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            City:
                                        </td>
                                        <td>
                                            <asp:TextBox ID="txtCity" runat="server" TabIndex="2" Width="200px" Text='<%# Bind("City") %>'>
                                            </asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            State:
                                            <asp:RequiredFieldValidator ID="rfvState" runat="server" ControlToValidate="txtState"
                                                Display="Dynamic" ErrorMessage=" Please enter Location State" Text="*" ValidationGroup="vgEvent"></asp:RequiredFieldValidator>
                                        </td>
                                        <td>
                                            <asp:TextBox ID="txtState" runat="server" Width="200" Text='<%# Bind("State") %>'></asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Postcode/Zip:
                                            <asp:RequiredFieldValidator ID="rfvZip" runat="server" ControlToValidate="txtZip"
                                                Display="Dynamic" ErrorMessage=" Please enter Location Postcode" Text="*" ValidationGroup="vgEvent"></asp:RequiredFieldValidator>
                                        </td>
                                        <td>
                                            <asp:TextBox ID="txtZip" runat="server" Width="200" Text='<%# Bind("Zip") %>'></asp:TextBox>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                            <td>
                                <%-- next table for client info--%>
                                <table id="Table1" cellspacing="1" cellpadding="1" width="300" border="0" class="module">
                                    <tr>
                                        <td>
                                        </td>
                                        <td>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Country
                                        </td>
                                        <td>
                                            <asp:DropDownList ID="ddlCountry" runat="server" DataSourceID="dsCountry" DataTextField="Description"
                                                DataValueField="ID" OnDataBound="ddlCountry_DataBound" Width="210">
                                            </asp:DropDownList>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Company Name:
                                        </td>
                                        <td valign="top">
                                            <asp:TextBox ID="txtCompany" runat="server" Width="200" Text='<%# Bind("HostCompanyName") %>'></asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Phone:
                                        </td>
                                        <td>
                                            <asp:TextBox ID="txtPhoneNo" runat="server" Width="200" Text='<%# Bind("HostPhoneNo") %>'></asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Fax:
                                        </td>
                                        <td>
                                            <asp:TextBox ID="txtFaxNo" runat="server" Width="200px" Text='<%# Bind("HostFaxNo") %>'></asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Mobile:
                                        </td>
                                        <td>
                                            <asp:TextBox ID="txtMobileNo" runat="server" TabIndex="2" Width="200px" Text='<%# Bind("HostMobileNo") %>'>
                                            </asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Email:
                                            <asp:RequiredFieldValidator ID="rfvEmail" runat="server" ControlToValidate="txtEmail"
                                                Display="Dynamic" ErrorMessage=" Please enter Email" Text="*" ValidationGroup="vgEvent"></asp:RequiredFieldValidator>
                                            <asp:RegularExpressionValidator ID="revEmail" runat="server" ControlToValidate="txtEmail"
                                                ErrorMessage="Invalid Email" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
                                        </td>
                                        <td valign="top">
                                            <asp:TextBox ID="txtEmail" runat="server" Width="200" Text='<%# Bind("HostEmail") %>'></asp:TextBox>
                                        </td>
                                    </tr>
                                </table>
                                <%--  End of next table for client info--%>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <hr />
                                <b>Enquiry Info:</b>
                            </td>
                        </tr>
                        <tr>
                            <td valign="top">
                                <%--  Start of Enquiry details--%>
                                <table id="Table4" cellspacing="1" cellpadding="1" width="300" border="0" class="module">
                                    <tr>
                                        <td>
                                            Start Date:
                                        </td>
                                        <td>
                                            <uc1:uc_calendar ID="calDateStart" runat="server" calFormat="d MMMM yyyy" ErrorMessage=" Please enter Reservation Start Date"
                                                TextBoxWidth="185" ValidationGroup="vgEvent" Visible="True" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            End Date:
                                        </td>
                                        <td>
                                            <uc1:uc_calendar ID="calDateEnd" runat="server" calFormat="d MMMM yyyy" ErrorMessage=" Please enter Reservation End Date"
                                                TextBoxWidth="185" ValidationGroup="vgEvent" Visible="True" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Nature of Function:
                                        </td>
                                        <td>
                                            <asp:DropDownList ID="ddlPackageType" runat="server" Width="210px" DataSourceID="sdsPackageType"
                                                DataTextField="Description" DataValueField="ID">
                                            </asp:DropDownList>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Venue:
                                        </td>
                                        <td>
                                            <asp:TextBox ID="txthotelRoom" runat="server" Width="200" Text='<%# Bind("HotelRoomName") %>'></asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td valign="top">
                                            Seating Arrangement:
                                        </td>
                                        <td>
                                            <asp:CheckBoxList ID="cblSeatingArrangment" runat="server" DataSourceID="sdsSeatingArrangement"
                                                DataTextField="Description" DataValueField="ID" OnDataBound="cblSeatingArrangment_DataBound">
                                            </asp:CheckBoxList>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                        </td>
                                        <td>
                                        </td>
                                    </tr>
                                </table>
                                <%-- End of Enquiry details--%>
                            </td>
                            <td valign="top">
                                <%-- start next table for Enquiry Details--%>
                                <table id="Table5" cellspacing="1" cellpadding="1" width="300" border="0" class="module">
                                    <tr>
                                        <td>
                                            Start Time:
                                        </td>
                                        <td>
                                            <asp:Label ID="Label3" runat="server" Visible="False"></asp:Label>
                                            <uc2:uc_time ID="Uc_time1" runat="server" Visible="True" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            End Time:
                                        </td>
                                        <td>
                                            <asp:Label ID="lblEndTime" runat="server" Visible="False"></asp:Label>
                                            <uc2:uc_time ID="timeEnd" runat="server" Visible="True" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            No of Pax:
                                        </td>
                                        <td>
                                            <asp:TextBox ID="TextBox1" runat="server" Width="200"></asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Remarks:
                                        </td>
                                        <td>
                                            <asp:TextBox ID="TextBox2" Text='<%# Bind("Remark") %>' runat="server" TextMode="MultiLine"
                                                Rows="5" Columns="40" TabIndex="5">
                                            </asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Reservation Status:
                                        </td>
                                        <td>
                                            <asp:RadioButtonList ID="rblReservedStatus" runat="server" DataSourceID="sdsReservedStatus"
                                                DataTextField="Description" DataValueField="ID" RepeatDirection="Horizontal">
                                            </asp:RadioButtonList>
                                        </td>
                                    </tr>
                                </table>
                                <%--  End next table for Enquiry Details--%>
                            </td>
                        </tr>
                        <tr>
                            <td>
                            </td>
                            <td>
                            </td>
                        </tr>
                    </table>
                    <%--QUOTATION--%>
                    <table id="Table6" cellspacing="2" cellpadding="1" width="100%" border="0" rules="none"
                        style="border-collapse: collapse; background: white;">
                        <tr>
                            <td colspan="2">
                                <hr />
                                <b>Quotation For Client:</b>
                            </td>
                        </tr>
                        <%--  Start of QUOTATION Form--%>
                        <tr>
                            <td colspan="2">
                                <table id="Table7" cellspacing="1" cellpadding="1" width="100%" border="0" class="module">
                                    <tr>
                                        <td width="77px">
                                            Quotation Name:
                                            <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="txtName"
                                                Display="Dynamic" ErrorMessage=" Please enter Location Name" Text="*" ValidationGroup="vgEvent"></asp:RequiredFieldValidator>
                                        </td>
                                        <td align="left">
                                            <asp:TextBox ID="TextBox4" runat="server" Width="400" Text='<%# Bind("QuotationName") %>'></asp:TextBox>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td valign="top">
                                <table id="Table7" cellspacing="1" cellpadding="1" width="300" border="0" class="module">
                                    <tr>
                                        <td>
                                            Package:
                                        </td>
                                        <td>
                                            <asp:DropDownList ID="DropDownList2" runat="server" Width="230px" DataSourceID="sdsPackageType"
                                                DataTextField="Description" DataValueField="ID">
                                            </asp:DropDownList>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Package Inclusive:
                                        </td>
                                        <td>
                                            <asp:DropDownList ID="DropDownList1" runat="server" Width="230px" DataSourceID="sdsPackageType"
                                                DataTextField="Description" DataValueField="ID">
                                            </asp:DropDownList>
                                            <br />
                                            <asp:Panel ID="Panel1" runat="server" Visible="false">
                                                <%--add others inclusive package --%>
                                                <asp:TextBox ID="TextBox6" runat="server" Width="200"></asp:TextBox>
                                                  
                                                <asp:ImageButton ImageUrl="~/IMAGES/BUTTONS/addIcon2.png" ToolTip="Add New Checklist Item"
                                                    Width="18" Height="18" ID="btnAddNewItem" runat="server" />
                                            </asp:Panel>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td valign="top">
                                            Backdrop Type:
                                        </td>
                                        <td>
                                            <asp:DropDownList ID="ddlBackdroptype" runat="server" DataSourceID="sdsBackdrop"
                                                DataTextField="Description" DataValueField="ID">
                                            </asp:DropDownList>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td valign="top">
                                            Backdrop Design:
                                        </td>
                                        <td>
                                            <asp:TextBox ID="txtBackdropText" runat="server" TextMode="MultiLine" Rows="5" Columns="40"
                                                TabIndex="5" Width="200">
                                            </asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td valign="top">
                                            Cancellation:
                                        </td>
                                        <td valign="top">
                                            <asp:TextBox ID="TextBox3" runat="server" TextMode="MultiLine" Width="200">
                                            </asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td valign="top">
                                            Reservation Cutt-Off Date:
                                        </td>
                                        <td valign="top">
                                            <uc1:uc_calendar ID="Uc_calendar1" runat="server" calFormat="d MMMM yyyy" ErrorMessage=" Please enter Reservation Cutt-Off Date"
                                                TextBoxWidth="185" ValidationGroup="vgEvent" Visible="True" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td valign="top">
                                            Mode Of Payment:
                                        </td>
                                        <td valign="top">
                                            <asp:DropDownList ID="DropDownList5" runat="server" DataSourceID="sdsPaymentType"
                                                DataTextField="Description" DataValueField="ID" Width="210">
                                            </asp:DropDownList>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                            <td>
                                <table id="Table8" cellspacing="1" cellpadding="1" width="300" border="0" class="module">
                                    <tr>
                                        <td valign="top">
                                            Equiptment Rental:
                                        </td>
                                        <td>
                                            <asp:CheckBoxList ID="cblRentalEquiptment" runat="server" DataSourceID="sdsFacilityList"
                                                DataTextField="Description" DataValueField="ID" OnDataBound="cblRentalEquiptment_DataBound">
                                            </asp:CheckBoxList>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <%-- End of QUOTATION Form--%>
                    </table>
                    <%-- END OF QUOTATION--%>
                    <table cellpadding="0" cellspacing="0" width="100%">
                        <tr>
                            <td>
                                <%--<asp:HiddenField ID="hdnReservationID" runat="server" Value='<%# Bind("ID") %>'  />
                                             <asp:HiddenField ID="hdnQuotationID" runat="server" Value='<%# Bind("QuotationID") %>'  />
                                            <asp:Label ID="Label4" runat="server" Visible="false" Text='<%# Bind("ID") %>'></asp:Label>
                                              <asp:Label ID="Label5" runat="server" Text='<%# Bind("QuotationID") %>' ></asp:Label>--%>
                            </td>
                            <td>
                            </td>
                        </tr>
                        <tr>
                            <td align="right" colspan="2">
                                <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                    runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
                                </asp:Button
                                <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                    CommandName="Cancel"></asp:Button>
                            </td>
                        </tr>
                    </table>
                </FormTemplate>
                <%-- End form--%>
            </EditFormSettings>
        </MasterTableView>
        <ClientSettings>
            <ClientEvents OnRowDblClick="RowDblClick" />
        </ClientSettings>
        <FilterMenu EnableImageSprites="False">
        </FilterMenu>
        <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
        </HeaderContextMenu>
    </telerik:RadGrid>
 
 
                <%--   DATA SOURCES--%>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:EMS %>"
        SelectCommand="GetHotelListOfEnquiry_ByHotelID" SelectCommandType="StoredProcedure">
        <SelectParameters>
            <%--   <asp:ControlParameter ControlID="ddlReservationStatus" DefaultValue="0" Name="ReservationStatusID"
                                        PropertyName="SelectedValue" Type="Int32" />
                                    <asp:Parameter Name="IsDeleted" Type="Boolean" DefaultValue="false" />--%>
            <asp:ControlParameter ControlID="ddlHotel" Name="HotelID" PropertyName="SelectedValue"
                Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="sdsPackageType" runat="server" ConnectionString="<%$ ConnectionStrings:EMS %>"
        SelectCommand="GetEventPackageType_ByID" SelectCommandType="StoredProcedure">
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="dsCountry" runat="server" ConnectionString="<%$ ConnectionStrings:EMSsql %>"
        SelectCommand="GetCountryList" SelectCommandType="StoredProcedure"></asp:SqlDataSource>
    <asp:SqlDataSource ID="sdsReservedStatus" runat="server" ConnectionString="<%$ ConnectionStrings:EMS %>"
        SelectCommand="GetHotelReservationStatus" SelectCommandType="StoredProcedure">
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="sdsSeatingArrangement" runat="server" ConnectionString="<%$ ConnectionStrings:EMS %>"
        SelectCommand="GetSeatingArrangement_byID" SelectCommandType="StoredProcedure">
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:EMS %>"
        SelectCommand="GetEventPackageType_ByID" SelectCommandType="StoredProcedure">
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="sdsFacilityList" runat="server" ConnectionString="<%$ ConnectionStrings:EMS %>"
        SelectCommand="GetHotelFacilityList" SelectCommandType="StoredProcedure"></asp:SqlDataSource>
    <asp:SqlDataSource ID="sdsPaymentType" runat="server" ConnectionString="<%$ ConnectionStrings:EMS %>"
        SelectCommand="GetPaymentType_ByID" SelectCommandType="StoredProcedure"></asp:SqlDataSource>
    <asp:SqlDataSource ID="sdsBackdrop" runat="server" ConnectionString="<%$ ConnectionStrings:EMS %>"
        SelectCommand="GetBackdropType" SelectCommandType="StoredProcedure"></asp:SqlDataSource>
 
</asp:Content>

really appreciate your help
thanks shinu,

0
Shinu
Top achievements
Rank 2
answered on 21 Jun 2012, 06:29 AM
Hello,

Since the CheckBoxList is inside FromTemplate, you cannot access the column values in edit mode. One suggestion is you can get the ID value while editing using DataKeyName. Since you have set DataKeyNames as ID, you can get the ID value while editing using the following approach.
C#:
protected void cblSeatingArrangment_DataBound(object sender, EventArgs e)
{
    CheckBoxList chklst = (CheckBoxList)sender;
    GridEditableItem eitem = (GridEditableItem)chklst.NamingContainer;
    string value = eitem.GetDataKeyValue("ID").ToString();
}

Thanks,
Shinu.
Tags
Grid
Asked by
Winwizardy
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Winwizardy
Top achievements
Rank 1
Share this question
or