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

Help how to get the grid bound column value

3 Answers 311 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sravanthi
Top achievements
Rank 1
sravanthi asked on 06 May 2011, 06:41 PM
Hi every one,

I want the grid bound column value when it is in edit mode
Here is my code.....In the following code the SERVICETYPE Grid boun colim is editable text box.When the user enters  some value to update it I need to get the text the user entered and validate it


<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ServiceType.ascx.cs" Inherits="Desktop_Modules_Service_Type_ServiceType" %>
<asp:Panel ID="pnlCompanyType" runat="server">
    
        <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="rgServiceType">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="rgServiceType" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="RadWindowManager1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />     
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server"></telerik:RadWindowManager>
        <br />       
        <telerik:RadGrid ID="rgServiceType" runat="server" DataSourceID="sdsServiceType"  Skin="Outlook" Width="97%"
            ShowStatusBar="True" AllowSorting="True" PageSize="10" GridLines="None" AllowPaging="True"
            AllowAutomaticUpdates="True" AllowAutomaticDeletes="True" AllowAutomaticInserts="True"
            OnItemUpdated="rgCompanyType_ItemUpdated" OnItemDeleted="rgCompanyType_ItemDeleted"
            OnItemInserted="rgCompanyType_ItemInserted" OnDataBound="rgCompanyType_DataBound" AutoGenerateColumns="False">
            <PagerStyle Mode="NextPrevAndNumeric" />
            <MasterTableView Width="100%" CommandItemDisplay="TopAndBottom" DataKeyNames="nSERVICEID,nSERVICETYPE"
                DataSourceID="sdsServiceType" HorizontalAlign="NotSet" EditMode="InPlace">
              <Columns>
                    <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                        <ItemStyle/>
                    </telerik:GridEditCommandColumn>
                    <telerik:GridBoundColumn UniqueName="SERVICEID" DataField="nSERVICEID" HeaderText="SERVICEID" ReadOnly="True" HeaderStyle-Width="10%" />
                    <telerik:GridBoundColumn DataField="nSERVICETYPE" HeaderText="SERVICETYPE" SortExpression="nSERVICETYPE"
                        UniqueName="SERVICETYPE" ColumnEditorID="GridTextBoxColumnEditor1">
                    </telerik:GridBoundColumn>
                    <telerik:GridButtonColumn ConfirmText="Delete this product?" ConfirmDialogType="RadWindow"
                        ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                        UniqueName="DeleteColumn">
                        <ItemStyle HorizontalAlign="Center"/>
                    </telerik:GridButtonColumn>
              </Columns>
              <EditFormSettings ColumnNumber="2" CaptionDataField="SEVICETYPE" CaptionFormatString="Edit Company {0}" InsertCaption="New SERVICETYPE">
                   <FormTableItemStyle Wrap="False"></FormTableItemStyle>
                    <FormCaptionStyle></FormCaptionStyle>
                    <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" BackColor="White"
                        Width="100%" />
                    <FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" BackColor="White" />
                    <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
                    <EditColumn ButtonType="ImageButton" InsertText="Insert Order" UpdateText="Update record"
                        UniqueName="EditCommandColumn1" CancelText="Cancel edit">
                    </EditColumn>
                    <FormTableButtonRowStyle HorizontalAlign="Right"></FormTableButtonRowStyle>
                </EditFormSettings>
            </MasterTableView>
            <ClientSettings>
                <ClientEvents  OnRowDblClick="RowDblClick" />
            </ClientSettings>
        </telerik:RadGrid>
        <telerik:GridTextBoxColumnEditor ID="GridTextBoxColumnEditor1" runat="server" TextBoxStyle-Width="180px" />
        <br />
        <asp:Label ID="lblMessage" runat="server" EnableViewState="false" />
        <br />
        <asp:SqlDataSource ID="sdsServiceType" runat="server"
            ConnectionString="<%$ ConnectionStrings:DotNetNukeConnectionString2 %>"
            SelectCommand="sp_ServiceTypeSelect" SelectCommandType="StoredProcedure"
            DeleteCommand="sp_ServiceTypeDelete" DeleteCommandType="StoredProcedure"
            InsertCommand="sp_ServiceTypeInsert" InsertCommandType="StoredProcedure"  
            UpdateCommand="sp_ServiceTypeUpdate" UpdateCommandType="StoredProcedure">
            <DeleteParameters>
                <asp:Parameter Name="nSERVICEID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="nSERVICEID" Type="Int32" />
                <asp:Parameter Name="nSERVICETYPE" Type="String" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="nSERVICETYPE" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>

        
        <!-- content end -->

</asp:Panel>


Please help me thanks

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 09 May 2011, 09:20 AM
Hello Sravanthi,

I hope this code library will help you to achieve your requirement.
Retrieving grid editor value client side

Thanks,
Princy.
0
sravanthi
Top achievements
Rank 1
answered on 09 May 2011, 03:58 PM
Hi Princy,
Thanks for reply.But it did not work for me.For me Edit mode is ---InPlace,As I posted in the previous thread
I just added this code .....but it does not work
protected void rgCompanyType_ItemCreated(object sender, GridItemEventArgs e)
    {
if (e.Item.IsInEditMode && e.item is GridEditFormItem)
        {
            GridEditFormItem editFormItem=(GridEditFormItem)e.Item;
            TextBox box = (TextBox)editFormItem.FindControl("TextBox1");
            rgServiceType.Controls.Add(new LiteralControl("<script type='text/javascript'>window['SERVICETYPE'] = '" + box.ClientID + "';</script>"));
        }
}
But it does nothing.
0
Mira
Telerik team
answered on 12 May 2011, 11:28 AM
Hello Sravanthi,

You can see how to access the edited item when edit mode is in place here.

I hope this helps.

Regards,
Mira
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
sravanthi
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
sravanthi
Top achievements
Rank 1
Mira
Telerik team
Share this question
or