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

Datagrid Postback Issue

1 Answer 19 Views
Grid
This is a migrated thread and some comments may be shown as answers.
MIS-GSC
Top achievements
Rank 1
MIS-GSC asked on 18 Dec 2013, 07:27 AM
Dear Sir,
The requirement is that there are s two buttons (Retrieve and Apply) and one updatepanel. When user clicked the "Retrieve" button, the grid will be populated by search filter (No a grid filter). After that user selected those row for "Approval" button. There is working table to generated the record for this page by session id
It is expected that when the "Apply" button is clicked, the working table field -"TICK" to be updated automatically. However, the 'TICK' didn't update. Please help
<telerik:radgrid id="rgdApproval" runat="server" autogeneratecolumns="False" cellspacing="0"
cssclass="NoPadding" gridlines="Vertical" groupingenabled="False" height=" 200px" width="98%"  ShowHeader="true"
AllowAutomaticUpdates="True"  onitemcommand="rgdApproval_ItemCommand"
AllowMultiRowSelection="true" >
<AlternatingItemStyle BackColor="#DCE6F1" Font-Names="Verdana" Font-Size="9pt"
Height="20px" />
<MasterTableView AllowMultiColumnSorting="false"  EditMode="Batch"
ClientDataKeyNames="EACCAPV_DOCNO" Summary="RadGrid table"
TableLayout="Fixed" 
Width="100%">
                       <PagerStyle AlwaysVisible="true" />
                                            <Columns>
                                               
                                               <telerik:GridClientSelectColumn  UniqueName="chkTick"  DataType ="System.Boolean" Display="true"  >
                                                        <HeaderStyle HorizontalAlign="Left" VerticalAlign="Middle" Width="50px" />
                                                        <ItemStyle HorizontalAlign="left" VerticalAlign="Middle" Width="50px" />
                                                </telerik:GridClientSelectColumn>
                                                <telerik:GridCheckBoxColumn     ReadOnly ="true" HeaderText="Out Pay"
                                                                                UniqueName="chkOUTPAY">
                                                         <HeaderStyle HorizontalAlign="Left" VerticalAlign="Middle" Width="60px" />
                                                         <ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" Width="60px" />
                                                </telerik:GridCheckBoxColumn>
                                                <telerik:GridBoundColumn ReadOnly ="true" DataField ="EACCAPV_OUTSIDEPAY"
                                                                         Visible ="false" HeaderText=""
                                                                         UniqueName="OUTSIDEPAY">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridTemplateColumn
                                                             HeaderText="Document No" UniqueName="grvDocumentNo">
                                                             <ItemTemplate>
                                                                 <asp:LinkButton ID="LnkEACCAPV_DOCNO" runat="server"
                                                                     CommandArgument="<%#Container.ItemIndex%>" CommandName="ViewDocNo"
                                                                     Text='<%# Bind("EACCAPV_DOCNO") %>'></asp:LinkButton>
                                                             </ItemTemplate>
                                                             <HeaderStyle HorizontalAlign="Left" VerticalAlign="Middle" Width="135px" />
                                                             <ItemStyle HorizontalAlign="Left" VerticalAlign="Top" Width="135px" />
                                                </telerik:GridTemplateColumn>
                                            </Columns>
                                            <GroupByExpressions>
                                                <telerik:GridGroupByExpression>
                                                     <GroupByFields>
                                                            <telerik:GridGroupByField FieldName="EACCAPV_CLMCCY"></telerik:GridGroupByField>
                                                     </GroupByFields>
                                                    <SelectFields>
                                                        <telerik:GridGroupByField FieldName="EACCAPV_CLMCCY" HeaderText=""></telerik:GridGroupByField>
                                                    </SelectFields>
                                                </telerik:GridGroupByExpression>
                                            </GroupByExpressions>
                                        </MasterTableView>
                                        <SortingSettings EnableSkinSortStyles="False" SortedBackColor="Azure" />
                                         <ClientSettings EnableRowHoverStyle="true"  >
                                             <Resizing AllowColumnResize="True" AllowRowResize="False"
                                                 EnableRealTimeResize="True" ResizeGridOnColumnResize="False" />
                                             <Selecting AllowRowSelect="True"    />
                                             <Scrolling AllowScroll="True" UseStaticHeaders="True" />
                                         </ClientSettings>
                                        <PagerStyle Height="20px" />
                                    </telerik:radgrid>
<telerik:radgrid id="rgdApproval" runat="server" autogeneratecolumns="False" cellspacing="0"
                                        cssclass="NoPadding" gridlines="Vertical" groupingenabled="False" height=" 200px" width="98%"  ShowHeader="true"
                                       AllowAutomaticUpdates="True"  onitemcommand="rgdApproval_ItemCommand"
                                         AllowMultiRowSelection="true" >
                                        <AlternatingItemStyle BackColor="#DCE6F1" Font-Names="Verdana" Font-Size="9pt"
                                                                Height="20px" />
                                        <MasterTableView AllowMultiColumnSorting="false"  EditMode="Batch"
                                                          ClientDataKeyNames="EACCAPV_DOCNO" Summary="RadGrid table"
                                                          TableLayout="Fixed"
                                                         Width="100%">
                                            <PagerStyle AlwaysVisible="true" />
                                            <Columns>
                                                
                                               <telerik:GridClientSelectColumn  UniqueName="chkTick"  DataType ="System.Boolean" Display="true"  >
                                                        <HeaderStyle HorizontalAlign="Left" VerticalAlign="Middle" Width="50px" />
                                                        <ItemStyle HorizontalAlign="left" VerticalAlign="Middle" Width="50px" />
                                                </telerik:GridClientSelectColumn>
                                                <telerik:GridCheckBoxColumn     ReadOnly ="true" HeaderText="Out Pay"
                                                                                UniqueName="chkOUTPAY">
                                                         <HeaderStyle HorizontalAlign="Left" VerticalAlign="Middle" Width="60px" />
                                                         <ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" Width="60px" />
                                                </telerik:GridCheckBoxColumn>
                                                <telerik:GridBoundColumn ReadOnly ="true" DataField ="EACCAPV_OUTSIDEPAY"
                                                                         Visible ="false" HeaderText=""
                                                                         UniqueName="OUTSIDEPAY">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridTemplateColumn
                                                             HeaderText="Document No" UniqueName="grvDocumentNo">
                                                             <ItemTemplate>
                                                                 <asp:LinkButton ID="LnkEACCAPV_DOCNO" runat="server"
                                                                     CommandArgument="<%#Container.ItemIndex%>" CommandName="ViewDocNo"
                                                                     Text='<%# Bind("EACCAPV_DOCNO") %>'></asp:LinkButton>
                                                             </ItemTemplate>
                                                             <HeaderStyle HorizontalAlign="Left" VerticalAlign="Middle" Width="135px" />
                                                             <ItemStyle HorizontalAlign="Left" VerticalAlign="Top" Width="135px" />
                                                </telerik:GridTemplateColumn>
                                            </Columns>
                                            <GroupByExpressions>
                                                <telerik:GridGroupByExpression>
                                                     <GroupByFields>
                                                            <telerik:GridGroupByField FieldName="EACCAPV_CLMCCY"></telerik:GridGroupByField>
                                                     </GroupByFields>
                                                    <SelectFields>
                                                        <telerik:GridGroupByField FieldName="EACCAPV_CLMCCY" HeaderText=""></telerik:GridGroupByField>
                                                    </SelectFields>
                                                </telerik:GridGroupByExpression>
                                            </GroupByExpressions>
                                        </MasterTableView>
                                        <SortingSettings EnableSkinSortStyles="False" SortedBackColor="Azure" />
                                         <ClientSettings EnableRowHoverStyle="true"  >
                                             <Resizing AllowColumnResize="True" AllowRowResize="False"
                                                 EnableRealTimeResize="True" ResizeGridOnColumnResize="False" />
                                             <Selecting AllowRowSelect="True"    />
                                             <Scrolling AllowScroll="True" UseStaticHeaders="True" />
                                         </ClientSettings>
                                        <PagerStyle Height="20px" />
                                    </telerik:radgrid>

Best Regards,
Judy Wong

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 20 Dec 2013, 02:34 PM
Hello Momoko,

From the provided information it is not clear enough what exactly you are trying to achieve. Furthermore, In the code snippet you have posted there is no data field "TICK".

Please have in mind that Automatic CRUD operations are available only when binding the grid to a declarative data source using the DataSourceID property. More information on this matter could be found at the following help article: "Automatic DataSource Operations".

Nevertheless, if you want to get reference to the selected item when you click on the "Apply" button, you could add an ID field to the DataKeyNames property of the MasterTableView (for and example: DataKeyNames="EACCAPV_DOCNO") and then handle the click event of the button as shown bellow:
protected void RadButton2_Click(object sender, EventArgs e)
{
    if (rgdApproval.SelectedItems.Count > 0)
    {
        GridDataItem item = rgdApproval.SelectedItems[0] as GridDataItem;
        string eaccapv_docno = (rgdApproval.SelectedItems[0] as GridDataItem).GetDataKeyValue("EACCAPV_DOCNO").ToString();
 
        //your manual update
    }
}

Here you could use the retrieved DataKeyValue to update the record as you please.

Hope that helps.


Regards,
Konstantin Dikov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
MIS-GSC
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or