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

Row select of a Radgrid in a repeater

1 Answer 122 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul Gothard
Top achievements
Rank 1
Paul Gothard asked on 22 Apr 2010, 02:57 PM
Hi,

I have a rad grid inside a repeater and all i want to do is get the row select to fire some server side code but I can not get the code to fire.

    <asp:Repeater ID="rptExaminations"
        runat="server"
        OnItemDataBound="rptExaminations_ItemDataBound"
        OnItemCommand="rptExaminations_ItemCommand"                
        EnableViewState="true">
        <ItemTemplate>
            <asp:Label ID="lblExaminationReference" runat="server" CssClass="summaryHeading"></asp:Label>
                      .......
            <atkins:RadGrid ID="grdExhibits"
                runat="server"
                AutoGenerateColumns="False"
                AllowSorting="False"
                AllowPaging="False"
                AllowMultiRowSelection="false"
                GridLines="None"
                ClientSettings-EnableRowHoverStyle="true"           
                >
                <ClientSettings>
                    <Selecting AllowRowSelect="true" />
                </ClientSettings>
                <MasterTableView NoMasterRecordsText="There are no exhbits">
                    <Columns>
                        <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" HeaderStyle-Width="25px" ItemStyle-Width="25px" CommandArgument="ExhibitSelected" />
                        <telerik:GridBoundColumn HeaderText="Witness Ref" UniqueName="WitnessReference" DataField="WitnessRef"
                            HeaderStyle-Width="150px">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Barcode" UniqueName="BarCode" DataField="Barcode"
                            HeaderStyle-Width="150px">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Short Description" UniqueName="ShortDescription"
                            DataField="ShortDescriptionId" HeaderStyle-Width="75px">
                        </telerik:GridBoundColumn>
                        <atkins:GridExpandTextColumn HeaderText="Description" UniqueName="Description" DataField="Description">
                        </atkins:GridExpandTextColumn>
                        <telerik:GridBoundColumn HeaderText="Current Location" UniqueName="CurrentLocation"
                            DataField="Location" HeaderStyle-Width="100px">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Seized By" UniqueName="ObtainedBy" DataField="ObtainedById"
                            ItemStyle-Width="100px">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Date / Time Seized" UniqueName="SeizedDate"
                            DataField="DateTimeObtained" DataFormatString="{0:mm/dd/yyyy hh:mm}" HeaderStyle-Width="100px">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Property Reference Number" UniqueName="PropertyReferenceNumber"
                            DataField="CPR" HeaderStyle-Width="150px">
                        </telerik:GridBoundColumn>
                        <atkins:GridExpandTextColumn HeaderText="Remarks" UniqueName="Remarks" DataField="AppendRemarks">
                        </atkins:GridExpandTextColumn>
                    </Columns>
                </MasterTableView>
            </atkins:RadGrid>
            <br class="clear" />
        </ItemTemplate>
    </asp:Repeater>

      #region examinations repeater
        protected void rptExaminations_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
            {
                return;
            }
            else
            {

                // populate the exhibits
                Atkins.Locard.Web.Controls.RadGrid grdExhibits = (Atkins.Locard.Web.Controls.RadGrid)e.Item.FindControl("grdExhibits");
                grdExhibits.DataSource = examination.Exhibits;
                grdExhibits.DataBind();

            }
        }

        protected void rptExaminations_ItemCommand(object sender, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "ExhibitSelected")
            {
                //todo
                int selectedIndex = rtsExaminations.SelectedIndex;
                RepeaterItem repeaterItem = rptExaminations.Items[selectedIndex];
                RadGrid grdExhibits = (RadGrid)repeaterItem.FindControl("grdExhibits");
                if (grdExhibits.SelectedItems.Count == 1)
                {
                    GridItem gridItem = grdExhibits.SelectedItems[0];
                    BarCode = gridItem.Attributes["BarCode"].ToString();
                }
                else
                {
                    BarCode = "";
                }
            }
        }

        #endregion

I'm sure its something simple i'm missing

1 Answer, 1 is accepted

Sort by
0
robertw102
Top achievements
Rank 1
answered on 22 Apr 2010, 08:41 PM
Firstly the GridClientSelectColumn does not postback when you select it. Now I notice you have the AllowRowSelect enabled. To handle the row click you would need to attach the event handler to the RadGrid control, not the repeater control. Even if you had a CommandName set inside the RadGrid it would not bubble up to the Repeater, the RadGrid control would handle all ItemCommands.

I hope that helps.
Tags
Grid
Asked by
Paul Gothard
Top achievements
Rank 1
Answers by
robertw102
Top achievements
Rank 1
Share this question
or