Get value of GridTemplateColumn in selected row in Grid?

4 posts, 0 answers
  1. Jerald
    Jerald avatar
    28 posts
    Member since:
    Jan 2016

    Posted 10 Aug 2018 Link to this post

    I need to retrieve the value of the docTitle GridTemplateColumn, but I'm not having any luck.  How can I modify my code to get the docTitle value of the selected row:

     

    Here's the grid markup:

    <telerik:RadGrid ID="rgVenDocs" runat="server" DataSourceID="sdsRgVenDocs" AutoGenerateColumns="False" AllowPaging="True" AllowSorting="True" AllowFilteringByColumn="True" ShowGroupPanel="True" Skin="Office2010Black" OnPreRender="rgVenDocs_PreRender" OnItemCommand="rgVenDocs_ItemCommand" OnSelectedIndexChanged="rgVenDocs_SelectedIndexChanged" ShowStatusBar="true" ViewStateMode="Enabled">
        <ClientSettings AllowDragToGroup="True" AllowColumnsReorder="True" ReorderColumnsOnClient="True" >
        </ClientSettings>
        <MasterTableView DataKeyNames="docIdPk" DataSourceID="sdsRgVenDocs" PagerStyle-AlwaysVisible="true">
            <Columns>
                <telerik:GridButtonColumn ButtonType="LinkButton" CommandName="Select" Text="Select"></telerik:GridButtonColumn>
                <telerik:GridBoundColumn DataField="docIdPk" ReadOnly="True" HeaderText="docIdPk" SortExpression="docIdPk" UniqueName="docIdPk" DataType="System.Int32" FilterControlAltText="Filter docIdPk column"></telerik:GridBoundColumn>                            
                <telerik:GridBoundColumn DataField="docFileName" HeaderText="docFileName" SortExpression="docFileName" UniqueName="docFileName" FilterControlAltText="Filter docFileName column"></telerik:GridBoundColumn>        
                <telerik:GridTemplateColumn DataField="docTitle" HeaderText="Document" UniqueName="docTitle" SortExpression="docTitle" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-Font-Bold="true">
                    <ItemTemplate>
                        <asp:LinkButton ID="lnkDownload" Text='<%# Eval("docTitle") %>' CommandArgument='<%# Eval("docPath") %>' runat="server" OnClick="lnkDownload_Click"></asp:LinkButton>              
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>

     

    Here's the SelectedIndexChanged code:

    protected void rgVenDocs_SelectedIndexChanged(object sender, EventArgs e)
    {  
        foreach (GridDataItem item in rgVenDocs.SelectedItems)
    {  
    doctitletest.Text = item["docTitle"].Text;
    }
    }

     

     

  2. Jerald
    Jerald avatar
    28 posts
    Member since:
    Jan 2016

    Posted 10 Aug 2018 in reply to Jerald Link to this post

    I think what I'm looking for is along the same lines as the post located here ...https://www.telerik.com/forums/access-row-values-from-item-command
  3. Jerald
    Jerald avatar
    28 posts
    Member since:
    Jan 2016

    Posted 10 Aug 2018 in reply to Jerald Link to this post

    I think what I'm looking for is something similar to the following post:  https://www.telerik.com/forums/access-row-values-from-item-command
  4. Jerald
    Jerald avatar
    28 posts
    Member since:
    Jan 2016

    Posted 10 Aug 2018 Link to this post

    Nevermind, I got it.  I needed to find the control instead.

     

    LinkButton lb = (LinkButton)item.FindControl("lnkDownload");
                    doctitletest.Text = lb.Text;
Back to Top