Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8500669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:00:32+00:00 2026-06-11T01:00:32+00:00

I have a blank Repeater nested inside a column in a GridView and want

  • 0

I have a blank Repeater nested inside a column in a GridView and want to use a button in the GridView to populate the Repeater on demand via code behind. I am having difficulties referencing the repeater inside my button’s onCommand sub.

Here is the relevant markup:

<asp:GridView ID="Submission" runat="server" AllowPaging="true" AllowSorting="true" />
            <Columns>
                ..........
                <asp:TemplateField HeaderText="Action">
                    <ItemTemplate>
                        <asp:ImageButton ID="AdminEditSubmission" runat="server" ImageUrl="edit_15.png"
                            alt="" OnCommand="loadDetails" CommandArgument="X" />
                    </ItemTemplate>
                </asp:TemplateField>
                ..........
                <asp:TemplateField>
                    <ItemTemplate>
                                <asp:Repeater ID="RptSubmissionDetail" runat="server">
                                </asp:Repeater>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>

For the sake of this small example, I will simply try to update the repeater’s header with “Hello world”. However, when it gets to the last line, I get the dreaded “Object reference not set to an instance of an object” error.

    Sub loadDetails(sender As Object, e As CommandEventArgs)
        Dim rpt As Repeater = CType(Page.FindControl("RptsSubmissionDetail"), Repeater)
        Dim tmpHdr As TemplateBuilder = New TemplateBuilder
        tmpHdr.AppendLiteralString("Hello World")
        rpt.HeaderTemplate = tmpHdr
    End Sub

Can anyone tell me how to reference this repeater from my ImageButton click sub? I have tried several, with Page.FindControl(“RptsSubmissionDetail”) only being my latest attempt.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T01:00:34+00:00Added an answer on June 11, 2026 at 1:00 am

    In GridView’s RowCommand you need to use FindControl on the GridViewRow:

    Sub Submission_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
        If e.CommandName = "loadDetails" Then
          ' Convert the row index stored in the CommandArgument
          ' property to an Integer.
          Dim index = Convert.ToInt32(e.CommandArgument)  
          ' Retrieve the row that contains the button clicked 
          ' by the user from the Rows collection.
          Dim row = Submission.Rows(index)  
          Dim repeater = DirectCast(row.FindControl("RptSubmissionDetail"), Repeater)
        End If
    End Sub
    

    From the ImageButton’s click event it’s nearly the same. Cast the sender argument to the ImageButton and it’s NamingContainer property to the GridViewRow. Then use FindControl as shown above:

    Sub ImageButton_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim img = DirectCast(sender, ImageButton)
        Dim row = DirectCast(img.NamingContainer, GridViewRow)
        Dim repeater = DirectCast(row.FindControl("RptSubmissionDetail"), Repeater)
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created blank C#/XAML Windows 8 application. Add simple XAML code: <Page x:Class=Blank.MainPage
I have created blank Asp.Net-MVC 3 web application and want to write my own
I have a csv file which may have empty or blank rows. I want
I have a field that may be blank, so I need to use Object.try,
I have a repeater with a checkbox inside of it. <tr class=datarow> <td style=display:
I have an image control inside a repeater. I would like to exclude/ignore a
I have an application with star rating. Star rating inside repeater. <asp:Repeater ID=reptweet runat=server
I have a DataRepeater with a GridView inside to display some tables from a
I have the following html (inside ASP.NET Repeater): <div class=team_member> <a class=teamMemberLink href='<%# Profile.aspx?uID=
I have a button in a rather complex repeater, it has to have UseSubmitBehavior=False

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.