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 8341361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:27:26+00:00 2026-06-09T05:27:26+00:00

I have a repeator control in my aspx page. I am binding data to

  • 0

I have a repeator control in my aspx page. I am binding data to it on page load event. It is displaying the repeater control. But when I try to find the controls present in repeater control in repeater_ItemDataBound event, I get System.NullReferenceException: Object reference not set to an instance of an object.

Following is the repeator control in my aspx page,

<asp:Repeater ID="rptrSurvey" runat="server" OnItemDataBound="rptrSurvey_ItemDataBound">
<HeaderTemplate>
<table cellpadding='0' cellspacing='0' width='100%' class='tableClass'>
  <tr class='trClass' align='right'>
       <th class='full'>Id</th>
       <th class='full'>Questions</th>
       <th class='full'>Answers</th>
  </tr>
</HeaderTemplate>
<ItemTemplate>
   <tr id="sr<%#Container.ItemIndex %>" class='trClass' style='width:100%'>
   <td id="st1<%#Container.ItemIndex %>" class='first' style='width:5%'>              <%#Eval("question_id") %></td>
   <td id="st2<%#Container.ItemIndex %>" class='first' style='width:60%'><%#Eval("question_description") %></td>                    
   <div id="Div1" runat="server" Visible='<%# Convert.ToInt32(Eval("question_type_id")) == 1 %>' >
   <td id="st3<%#Container.ItemIndex %>" class='last' style='width:35%'>
   <input id="rdoYes<%#Container.ItemIndex %>" value="YES" name="yes_no_na<%#Container.ItemIndex %>" type="radio"></input>YES
   <input id="rdoNo<%#Container.ItemIndex %>" value="NO" name="yes_no_na<%#Container.ItemIndex %>" type="radio"></input>NO
   <input id="rdoNa<%#Container.ItemIndex %>" value="N/A" name="yes_no_na<%#Container.ItemIndex %>" type="radio"></input>N/A
   </td>
   </div>
   <div id="Div2" runat="server" visible='<%# Convert.ToInt32(Eval("question_type_id")) != 1 %>'>
   <td id="st4<%#Container.ItemIndex %>" class='last' style='width:35%'>
   <textarea id="txtComment<%#Container.ItemIndex %>" cols="1" rows="1" style='width:98%; height:100px'></textarea>
   </td>
   </div>
   </tr>
   </ItemTemplate>
   <FooterTemplate>
   </table>
   </FooterTemplate>
   </asp:Repeater>

Following is the ItemDataBound Event,

protected void rptrSurvey_ItemDataBound(Object Sender, RepeaterItemEventArgs e)
{
    var m = HRLetterDatabase.GetSurveyData(hSurveyId.Value);

    foreach (var row in m)
    {
        if (row.question_type_id == 1)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                HtmlInputRadioButton inputYes = (HtmlInputRadioButton)e.Item.FindControl("rdoYes" + e.Item.ItemIndex);
                if (row.answer == "YES")
                {
                    inputYes.Checked = true;
                    //do something with val
                }
            }
        }
    }
}
  • 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-09T05:27:29+00:00Added an answer on June 9, 2026 at 5:27 am

    try adding

    runat="server"
    

    to your radiobutton input controls

    edit:
    you cannot dynamically bind IDs to your controls.

    <input id="rdoYes" value="YES" type="radio" runat="server" />
    

    can be manipulated on the OnItemDataBound event by:

    protected void rptrSurvey_ItemDataBound(Object Sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
        {
            HtmlInputRadioButton inputYes = (HtmlInputRadioButton)e.Item.FindControl("rdoYes");
            // set value as required
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Repeater control in my aspx page: <asp:Repeater ID=repeater runat=server EnableViewState=false> <ItemTemplate>
I have a asp.net repeater control in a aspx page, with runat=server and an
I have an aspx page with repeater control on it used for showing the
I have a repeater of controls on an aspx page. I am trying to
I have a repeater control on my .aspx page. There are times where a
I have nested repeaters on my aspx page.In the outer repeater I am displaying
I have a Linkbutton inside a Repeater control. My code in the aspx page
I have a Repeater control that is creating a dynamic amount of CheckBoxList controls
I have a designed landing page in asp.net 4.0 i am using repeater control
I have a nested repeater set up but the child repeater control is not

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.