0

Hi,

I am having an issue where i want to be able to read the value of a particular cell from a selected row in telerik radgrid.

I am using the following code:

<%@ Page Language="C#" MasterPageFile="~/Page.master" AutoEventWireup="true" CodeFile="ProductSignup.aspx.cs" Inherits="ProductSignup" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <style type="text/css">
        .style2
        {
            width: 100%;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <table class="style2">
        <tr>
            <td>
                <asp:Panel ID="Panel1" runat="server" Height="416px">
                    Select A Product Type:<br />
                    <asp:RadioButton ID="rdPersonal" runat="server" AutoPostBack="True" 
                        GroupName="G2" oncheckedchanged="rdPersonal_CheckedChanged" 
                        Text="Personal Drives" />
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:RadioButton ID="rdBusiness" runat="server" AutoPostBack="True" 
                        GroupName="G2" oncheckedchanged="rdBusiness_CheckedChanged" 
                        Text="Business Drive" />
                    <br />
                    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:Cloud %>" 
                        SelectCommand="SELECT * FROM [CLOUD_ITEM_MST] WHERE ([item_id] LIKE '%' + @item_id + '%') ORDER BY [item_price_Iy]">
                        <SelectParameters>
                            <asp:SessionParameter Name="item_id" SessionField="drive type" Type="String" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                    <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" 
                        CellSpacing="0" DataSourceID="SqlDataSource1" GridLines="None" 
                        Width="577px" AllowSorting="True" ShowGroupPanel="True">
                        <FilterMenu EnableImageSprites="False">
                        </FilterMenu>
                        <ClientSettings allowdragtogroup="True">
                            <Selecting AllowRowSelect="True" CellSelectionMode="None" />
                        </ClientSettings>
                        <MasterTableView AutoGenerateColumns="False" DataKeyNames="item_id" 
                            DataSourceID="SqlDataSource1" allowsorting="False">
                            <CommandItemSettings ExportToPdfText="Export to PDF" />
                            <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" 
                                Visible="True">
                                <HeaderStyle Width="20px" />
                            </RowIndicatorColumn>
                            <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" 
                                Visible="True">
                                <HeaderStyle Width="20px" />
                            </ExpandCollapseColumn>
                            <Columns>
                                <telerik:GridBoundColumn DataField="item_id" 
                                    FilterControlAltText="Filter item_id column" HeaderText="item_id" 
                                    ReadOnly="True" SortExpression="item_id" UniqueName="item_id">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="item_name" 
                                    FilterControlAltText="Filter item_name column" HeaderText="item_name" 
                                    SortExpression="item_name" UniqueName="item_name">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="item_price_Iy" DataType="System.Double" 
                                    FilterControlAltText="Filter item_price_Iy column" HeaderText="item_price_Iy" 
                                    SortExpression="item_price_Iy" UniqueName="item_price_Iy">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="item_price_2y" DataType="System.Double" 
                                    FilterControlAltText="Filter item_price_2y column" HeaderText="item_price_2y" 
                                    SortExpression="item_price_2y" UniqueName="item_price_2y">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="item_price_3y" 
                                    FilterControlAltText="Filter item_price_3y column" HeaderText="item_price_3y" 
                                    SortExpression="item_price_3y" UniqueName="item_price_3y">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="item_max_users" DataType="System.Double" 
                                    FilterControlAltText="Filter item_max_users column" HeaderText="item_max_users" 
                                    SortExpression="item_max_users" UniqueName="item_max_users">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="item_size" DataType="System.Double" 
                                    FilterControlAltText="Filter item_size column" HeaderText="item_size" 
                                    SortExpression="item_size" UniqueName="item_size">
                                </telerik:GridBoundColumn>
                            </Columns>
                            <EditFormSettings>
                                <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                                </EditColumn>
                            </EditFormSettings>
                        </MasterTableView>
                    </telerik:RadGrid>
                    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
                    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
                    <br />
                </asp:Panel>
            </td>
            <td>
                <asp:Panel ID="Panel2" runat="server">
                </asp:Panel>
            </td>
        </tr>
    </table>
</asp:Content>

c# code behind is as follows:

protected void Button1_Click(object sender, EventArgs e)
    {
        string s3;
        foreach (GridDataItem selectinganItem in RadGrid1.MasterTableView.Items)
        {
            if (selectinganItem.Selected)
            {
                Label1.Text = selectinganItem["item_price_iy"].Text;
            }
        }
    }

Whenever i select a row and click on the button - the label1.text does not change. In debugging it shows that the radgrid row selected value is always false.

I used similar code elsewhere in my site and it works fine.

Please help.

2
Contributors
1
Reply
3
Views
4 Years
Discussion Span
Last Post by LastMitch
0

Whenever i select a row and click on the button - the label1.text does not change. In debugging it shows that the radgrid row selected value is always false.

I am assuming you are using this:

http://demos.telerik.com/aspnet-ajax/grid/examples/client/selecting/defaultcs.aspx

I don't know what is string s3?

Read this:

http://www.telerik.com/help/aspnet-ajax/grid-accessing-cells-and-rows.html

For your button that goes with the link above:

protected void Button1_Click(object sender, EventArgs e)
   {
       foreach (GridDataItem item in RadGrid1.MasterTableView.SelectedItems) 
       {
           string name = item["item_price_iy"].Text;
       }
   }

Edited by LastMitch: grammer

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.