Row select of a Radgrid in a repeater

2 posts, 0 answers
  1. Paul Gothard
    Paul Gothard avatar
    3 posts
    Member since:
    Nov 2008

    Posted 22 Apr 2010 Link to this post

    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
  2. robertw102
    robertw102 avatar
    265 posts
    Member since:
    Jul 2007

    Posted 22 Apr 2010 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top