title: update data In Repeater Control Using Button Outside It
body: <p>I am having 5 div tags,in each div tag I am having repeater control.I want to allow user update information if he want.So on form load,I am retrieving all information from table,so one can update information.But I am unable to do this.I am giving the code for 3 repeater control.I tried this on button update click.Problem is when i clicked  on update button it is not loop through first 4 repeater's for each loop,it just loop through the last for each loop.And I have created store procedure to update information.So,I want to send all parameters to it like:</p>
  
  <pre><code>enter code here
  ob.UpdateProfile(profileid, candiid, pheadline, ethnicity, religion, caste, starsign,  purpose, maritalstatus, lang, htid, height, wt, skincolor, eyesight, abtme, diet, drink, smoking, drug, frndship, schoolname, schpassyr, collegename, collgpassyr, compwebsite);
  
  enter code here
  foreach (RepeaterItem repItem in repProfileInfo.Items)
          {
              TextBox tProfileHeadline = repItem.FindControl("txtProfileHeadline") as   TextBox;
              pheadline = tProfileHeadline.Text;
              DropDownList ddlEthnicity = repItem.FindControl("drpEthnicity") as DropDownList;
              ethnicity = ddlEthnicity.SelectedItem.Text;
              DropDownList ddlReligion = repItem.FindControl("drpReligion") as DropDownList;
              religion = ddlReligion.SelectedItem.Text;
  
              TextBox tCaste = repItem.FindControl("txtCaste") as TextBox;
              caste = tCaste.Text;
              DropDownList ddlStarSign = repItem.FindControl("drpStarSign") as DropDownList;
              starsign = ddlStarSign.SelectedItem.Text;
              DropDownList ddlPurpose = repItem.FindControl("drpPurpose") as DropDownList;
              purpose = ddlPurpose.SelectedItem.Text;
              DropDownList ddlMaritalStatus = repItem.FindControl("drpMaritalStatus") as DropDownList;
              maritalstatus = ddlMaritalStatus.SelectedItem.Text;
              TextBox tLanguage = repItem.FindControl("txtLanguage") as TextBox;
              lang = tLanguage.Text;
              TextBox tSchoolName = repItem.FindControl("txtSchoolName") as TextBox;
              schoolname = tSchoolName.Text;
              DropDownList ddlSchoolPassYr = repItem.FindControl("drpSchoolPassYr") as DropDownList;
              schpassyr = ddlSchoolPassYr.SelectedItem.Text;
              TextBox tCollegeName = repItem.FindControl("txtCollegeName") as TextBox;
              collegename = tCollegeName.Text;
              DropDownList ddlCollegePassYr = repItem.FindControl("drpCollegePassYr") as DropDownList;
              collgpassyr = ddlCollegePassYr.SelectedItem.Text;
              TextBox tCompanyWebsite = repItem.FindControl("txtCompanyWebsite") as TextBox;
              compwebsite = tCompanyWebsite.Text;
          }
          foreach(RepeaterItem repItem1 in repPhysicalInfo.Items)
          {
              DropDownList ddlHeight = repItem1.FindControl("drpHeight") as DropDownList;
              htid =ddlHeight.SelectedValue;
              height = ddlHeight.SelectedItem.Text;
  
              TextBox tWeight = repItem1.FindControl("txtWeight") as TextBox;
              wt = tWeight.Text;
              DropDownList ddlSkinColor = repItem1.FindControl("drpSkinColor") as   DropDownList;
              skincolor = ddlSkinColor.SelectedItem.Text;
              DropDownList ddlEyeSight = repItem1.FindControl("drpEyeSight") as DropDownList;
              eyesight = ddlEyeSight.SelectedItem.Text;
          }
          foreach(RepeaterItem repItem2 in repAbootMe.Items)
          {
              TextBox tAboutMe = repItem2.FindControl("txtAboutMe") as TextBox;
              abtme = tAboutMe.Text;
              CheckBox chkFriendShip = repItem2.FindControl("chkActivateFriendship") as CheckBox;
              if (chkFriendShip.Checked == true)
  
                  frndship = "Yes";
              else
                  frndship = "No";
  
      }
  </code></pre>
  
  <p>As it is loop through the last for each loop,I am getting error in procedure,as it is not getting all its parameter.Variables I defined in first 4 repeater control loop,getting null value.So I want know how I can get information in all repeater controls,so i can update it.Give me any solution for this.Thanks in advance. </p>
  
  <p>Design code of web form:
      
                      
                          
                              
                          
                          
                              
                                  
                                      Height:
                                  
                                  
                                      ' Width="150px">
                                      
                                          4.10
                                          4.11
                                          5.0
                                          5.1
                                          5.2
                                          5.3
                                          5.4
                                          5.5</p>
  
  <pre><code>                                &lt;/asp:DropDownList&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;
                              &lt;td class="directorytdWidth"&gt;
                                  Weight
                              &lt;/td&gt;
                              &lt;td class="directoryTdPadding"&gt;
                                  &lt;asp:TextBox ID="txtWeight" runat="server" Text='&lt;%#Eval("wt") %&gt;' Width="150px"&gt;&lt;/asp:TextBox&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;
                              &lt;td class="directorytdWidth"&gt;
                                  Skin Color:
                              &lt;/td&gt;
                              &lt;td class="directoryTdPadding"&gt;
                                  &lt;asp:TextBox ID="txtSkinColor" runat="server" Text='&lt;%#Eval("skincolor")%&gt;' Width="150px"&gt;&lt;/asp:TextBox&gt;
                                  &lt;asp:DropDownList ID="drpSkinColor" runat="server"  Height="24px" Width="100px" Visible="false"&gt;
                                      &lt;asp:ListItem&gt;Wheatish&lt;/asp:ListItem&gt;
                                      &lt;asp:ListItem&gt;Fair&lt;/asp:ListItem&gt;
                                      &lt;asp:ListItem&gt;Tan/Brown&lt;/asp:ListItem&gt;
                                      &lt;asp:ListItem&gt;Dark&lt;/asp:ListItem&gt;
                                   &lt;/asp:DropDownList&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;
                              &lt;td class="directorytdWidth"&gt;
                                  Eye Sight:
                              &lt;/td&gt;
                               &lt;td class="directoryTdPadding"&gt;
                                  &lt;asp:TextBox ID="txtEyeSight" runat="server" Text='&lt;%#Eval("eyesight")%&gt;' Width="150px"&gt;&lt;/asp:TextBox&gt;
                                  &lt;asp:DropDownList ID="drpEyeSight" runat="server"    Height="24px" Width="100px" Visible="false"&gt;
                                      &lt;asp:ListItem&gt;Clear&lt;/asp:ListItem&gt;
                                      &lt;asp:ListItem&gt;Glasses&lt;/asp:ListItem&gt;
                                  &lt;/asp:DropDownList&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;
                      &lt;/ItemTemplate&gt;
                      &lt;FooterTemplate&gt;
                          &lt;/table&gt;&lt;/FooterTemplate&gt;
                  &lt;/asp:Repeater&gt;
  
              &lt;/div&gt;
              &lt;div id="aboutMe" runat="server" visible="false" style="margin-left: 50px; display: block"&gt;
                  &lt;asp:Repeater ID="repAbootMe" runat="server" OnItemDataBound="myAboutMe"&gt;
                      &lt;HeaderTemplate&gt;
                          &lt;table&gt;
                      &lt;/HeaderTemplate&gt;
                      &lt;ItemTemplate&gt;
                          &lt;tr&gt;
                              &lt;td class="directorytdWidth"&gt;
                                  About Me:
                              &lt;/td&gt;
                              &lt;td class="directoryTdPadding"&gt;
                                  &lt;asp:TextBox ID="txtAboutMe" runat="server"    Text='&lt;%#Eval("aboutMe")%&gt;' Width="200px"
                                      TextMode="MultiLine" Height="100px"&gt;&lt;/asp:TextBox&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;
                              &lt;td class="directorytdWidth"&gt;
                                  Active Friendship Zone:
                              &lt;/td&gt;
                              &lt;td class="directoryTdPadding"&gt;
                                  &lt;asp:TextBox ID="txtActiveFrndZone" runat="server"    Text='&lt;%#Eval("friendship")%&gt;'
                                      Width="100px"&gt;&lt;/asp:TextBox&gt;
                                  &lt;asp:CheckBox ID="chkActivateFriendship" runat="server" Text="Activate My Friendship Zone Profile"
                                      Checked="True" ForeColor="#000000" Visible="false"   /&gt;
                               &lt;/td&gt;
                          &lt;/tr&gt;
                      &lt;/ItemTemplate&gt;
                      &lt;FooterTemplate&gt;
                          &lt;/table&gt;&lt;/FooterTemplate&gt;
                  &lt;/asp:Repeater&gt;
  
              &lt;div id="otherInfo" runat="server" visible="false" style="margin-left: 50px; display: block"&gt;
                  &lt;asp:Repeater ID="repOtherInfo" runat="server" OnItemDataBound="myOtherInfo"&gt;
                      &lt;HeaderTemplate&gt;
                          &lt;table&gt;
                      &lt;/HeaderTemplate&gt;
                      &lt;ItemTemplate&gt;
                          &lt;tr&gt;
                              &lt;td class="directorytdWidth"&gt;
                                  Diet:
                              &lt;/td&gt;
                              &lt;td class="directoryTdPadding"&gt;
                                      &lt;asp:TextBox ID="txtDiet" runat="server" Text='&lt;%#Eval("diet")%&gt;' Width="150px"&gt;&lt;/asp:TextBox&gt;
                                      &lt;asp:DropDownList ID="drpDiet" runat="server"  Height="24px" Width="100px" Visible="false"&gt;
                                          &lt;asp:ListItem&gt;&lt;/asp:ListItem&gt;
                                      &lt;asp:ListItem&gt;Veg&lt;/asp:ListItem&gt;
                                      &lt;asp:ListItem&gt;Non-Veg&lt;/asp:ListItem&gt;
                                  &lt;/asp:DropDownList&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;
                              &lt;td class="directorytdWidth"&gt;
                                  Drink:
                              &lt;/td&gt;
                              &lt;td class="directoryTdPadding"&gt;
                                  &lt;asp:TextBox ID="txtDrink" runat="server"    Text='&lt;%#Eval("drink")%&gt;' Width="150px"&gt;&lt;/asp:TextBox&gt;
                                  &lt;asp:DropDownList ID="drpDrinks" runat="server"   Height="24px" Width="100px" Visible="false"&gt;
                                      &lt;asp:ListItem&gt;&lt;/asp:ListItem&gt;
                                      &lt;asp:ListItem&gt;Don't Drink&lt;/asp:ListItem&gt;
                                      &lt;asp:ListItem&gt;Drink Socially&lt;/asp:ListItem&gt;
                                      &lt;asp:ListItem&gt;Drink like fish&lt;/asp:ListItem&gt;
                                  &lt;/asp:DropDownList&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;
                              &lt;td class="directorytdWidth"&gt;
                                  Smoke:
                              &lt;/td&gt;
                              &lt;td class="directoryTdPadding"&gt;
                                  &lt;asp:TextBox ID="txtSmoke" runat="server"   Text='&lt;%#Eval("smoke")%&gt;' Width="150px"&gt;&lt;/asp:TextBox&gt;
                                  &lt;asp:DropDownList ID="drpSmoking" runat="server"  Height="24px" Width="100px" Visible="false"&gt;
                                      &lt;asp:ListItem&gt;&lt;/asp:ListItem&gt;
                                      &lt;asp:ListItem&gt;Don't Smoke&lt;/asp:ListItem&gt;
                                      &lt;asp:ListItem&gt;Smoke Socially&lt;/asp:ListItem&gt;
                                      &lt;asp:ListItem&gt;Smoker&lt;/asp:ListItem&gt;
                                  &lt;/asp:DropDownList&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;
                              &lt;td class="directorytdWidth"&gt;
                                  Drugs:
                              &lt;/td&gt;
                              &lt;td class="directoryTdPadding"&gt;
                                  &lt;asp:TextBox ID="txtDrug" runat="server" Text='&lt;%#Eval("drug")%&gt;' Width="150px"&gt;&lt;/asp:TextBox&gt;
                                  &lt;asp:DropDownList ID="drpDrug" runat="server"  Height="24px" Width="100px" Visible="false"&gt;
                                      &lt;asp:ListItem&gt;&lt;/asp:ListItem&gt;
                                      &lt;asp:ListItem&gt;No Drugs&lt;/asp:ListItem&gt;
                                      &lt;asp:ListItem&gt;Druggi&lt;/asp:ListItem&gt;
                                  &lt;/asp:DropDownList&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;
                      &lt;/ItemTemplate&gt;
                      &lt;FooterTemplate&gt;
                          &lt;/table&gt;&lt;/FooterTemplate&gt;
                  &lt;/asp:Repeater&gt;
  
              &lt;/div&gt;
              &lt;div id="contactInfo" runat="server" visible="false" style="margin-left: 50px; display: block"&gt;
                  &lt;asp:Repeater ID="repContactInfo" runat="server"    OnItemDataBound="myContactInfo"&gt;
                      &lt;HeaderTemplate&gt;
                          &lt;table&gt;
                      &lt;/HeaderTemplate&gt;
                      &lt;ItemTemplate&gt;
                              &lt;tr&gt;
                                  &lt;td class="directorytdWidth"&gt;
                                      First Name:
                                  &lt;/td&gt;
                                  &lt;td class="directoryTdPadding"&gt;
                                      &lt;asp:TextBox ID="txtFirstName" runat="server"   Width="150px" Text='&lt;%#Eval("firstName")%&gt;'&gt;&lt;/asp:TextBox&gt;
                                  &lt;/td&gt;
                              &lt;/tr&gt;
                              &lt;tr&gt;
                              &lt;td class="directorytdWidth"&gt;
                                  Last Name:
                              &lt;/td&gt;
                              &lt;td class="directoryTdPadding"&gt;
                                   &lt;asp:TextBox ID="txtLastName" runat="server" Width="150px" Text='&lt;%#Eval("lastName")%&gt;'&gt;&lt;/asp:TextBox&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;
                              &lt;td class="directorytdWidth"&gt;
                                  Gender:
                              &lt;/td&gt;
                              &lt;td class="directoryTdPadding"&gt;
                                  &lt;asp:TextBox ID="txtGender" runat="server" Width="100px" Text='&lt;%#Eval("gender")%&gt;'&gt;&lt;/asp:TextBox&gt;
                                  &lt;asp:RadioButtonList ID="radioGender" runat="server" RepeatColumns="2" Visible="false"&gt;
                                      &lt;asp:ListItem Text="Male" Value="M"&gt;&lt;/asp:ListItem&gt;
                                      &lt;asp:ListItem Text="Female" Value="F"&gt;  &lt;/asp:ListItem&gt;
                                  &lt;/asp:RadioButtonList&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;
                              &lt;td class="directorytdWidth"&gt;
                                  Address:
                              &lt;/td&gt;
                              &lt;td class="directoryTdPadding"&gt;
                                  &lt;asp:TextBox ID="txtAdd" runat="server" Width="200px" Text='&lt;%#Eval("candiAddress")%&gt;'
                                      TextMode="MultiLine" Height="75px"&gt;&lt;/asp:TextBox&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;
                              &lt;td class="directorytdWidth"&gt;
                                  Country:
                              &lt;/td&gt;
                              &lt;td class="directoryTdPadding"&gt;
                                  &lt;asp:TextBox ID="txtCountry" runat="server" Width="150px" Text='&lt;%#Eval("countryName")%&gt;'&gt;&lt;/asp:TextBox&gt;
                                  &lt;asp:DropDownList ID="drpCountry" runat="server" Width="150px" Height="24px" Visible="false"
                                      AutoPostBack="true"   OnSelectedIndexChanged="drpCountry_SelectedIndexChanged"&gt;
                                  &lt;/asp:DropDownList&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;
                              &lt;td class="directorytdWidth"&gt;
                                  State:
                              &lt;/td&gt;
                              &lt;td class="directoryTdPadding"&gt;
                              &lt;asp:TextBox ID="txtState" runat="server" Width="150px" Text='&lt;%#Eval("stateName")%&gt;'&gt;&lt;/asp:TextBox&gt;
                              &lt;asp:DropDownList ID="drpState" runat="server"  Width="150px" Visible="false" Height="24px"
                                  AutoPostBack="true" OnSelectedIndexChanged="drpState_SelectedIndexChanged"&gt;
                              &lt;/asp:DropDownList&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;td class="directorytdWidth"&gt;
                              City:
                          &lt;/td&gt;
                          &lt;td class="directoryTdPadding"&gt;
                              &lt;asp:TextBox ID="txtCity" runat="server" Width="150px" Text='&lt;%#Eval("cityName")%&gt;'&gt;&lt;/asp:TextBox&gt;
                              &lt;asp:DropDownList ID="drpCity" runat="server" Width="150px" Height="24px" Visible="false"
                                  AutoPostBack="true"&gt;
                              &lt;/asp:DropDownList&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;td class="directorytdWidth"&gt;
                              Postal Code:
                          &lt;/td&gt;
                          &lt;td class="directoryTdPadding"&gt;
                              &lt;asp:TextBox ID="txtPostalCode" runat="server" Width="150px" Text='&lt;%#Eval("pincode")%&gt;'&gt;&lt;/asp:TextBox&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;td class="directorytdWidth"&gt;
                              Landline:
                          &lt;/td&gt;
                          &lt;td class="directoryTdPadding"&gt;
                              &lt;asp:TextBox ID="txtLandline" runat="server" Width="150px" Text='&lt;%#Eval("landline")%&gt;'&gt;&lt;/asp:TextBox&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;td class="directorytdWidth"&gt;
                              Mobile Number:
                          &lt;/td&gt;
                          &lt;td class="directoryTdPadding"&gt;
                              &lt;asp:TextBox ID="txtMobile" runat="server" Width="150px" Text='&lt;%#Eval("mobile")%&gt;'&gt;&lt;/asp:TextBox&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;td class="directorytdWidth"&gt;
                              Date of Birth:
                          &lt;/td&gt;
                          &lt;td class="directoryTdPadding"&gt;
                              &lt;asp:TextBox ID="txtDob" runat="server" Width="150px" Text='&lt;%#Eval("dob")%&gt;'&gt;&lt;/asp:TextBox&gt;
                              &lt;asp:DropDownList ID="drpYear" runat="server" Visible="false" Height="24px" Width="80px"
                                  AutoPostBack="true"&gt;
                              &lt;/asp:DropDownList&gt;
                              &amp;nbsp;&amp;nbsp;
                              &lt;asp:DropDownList ID="drpMonth" runat="server" Height="24px" Width="80px" OnSelectedIndexChanged="drpMonth_SelectedIndexChanged"
                                  AutoPostBack="true" Visible="false"&gt;
                                  &lt;asp:ListItem Value="1" Selected="True"&gt;January&lt;/asp:ListItem&gt;
                                  &lt;asp:ListItem Value="2"&gt;February&lt;/asp:ListItem&gt;
                                  &lt;asp:ListItem Value="3"&gt;March&lt;/asp:ListItem&gt;
                                  &lt;asp:ListItem Value="4"&gt;April&lt;/asp:ListItem&gt;
                                  &lt;asp:ListItem Value="5"&gt;May&lt;/asp:ListItem&gt;
                                  &lt;asp:ListItem Value="6"&gt;June&lt;/asp:ListItem&gt;
                                  &lt;asp:ListItem Value="7"&gt;July&lt;/asp:ListItem&gt;
                                  &lt;asp:ListItem Value="8"&gt;August&lt;/asp:ListItem&gt;
                                  &lt;asp:ListItem Value="9"&gt;September&lt;/asp:ListItem&gt;
                                  &lt;asp:ListItem Value="10"&gt;October&lt;/asp:ListItem&gt;
                                  &lt;asp:ListItem Value="11"&gt;November&lt;/asp:ListItem&gt;
                                  &lt;asp:ListItem Value="12"&gt;December&lt;/asp:ListItem&gt;
                              &lt;/asp:DropDownList&gt;
                              &amp;nbsp;&amp;nbsp;
                              &lt;asp:DropDownList ID="drpDate" runat="server" Height="24px" Width="50px" Visible="false"
                                  AutoPostBack="true"&gt;
                              &lt;/asp:DropDownList&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;td class="directorytdWidth"&gt;
                              Email Address:
                          &lt;/td&gt;
                          &lt;td class="directoryTdPadding"&gt;
                              &lt;asp:TextBox ID="txtEmail" runat="server" Width="150px" Text='&lt;%#Eval("altEmail")%&gt;'&gt;&lt;/asp:TextBox&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/ItemTemplate&gt;
                  &lt;FooterTemplate&gt;
                      &lt;/table&gt;&lt;/FooterTemplate&gt;
              &lt;/asp:Repeater&gt;
          &lt;/div&gt;
          &lt;div style="text-align: center"&gt;
              &lt;asp:Button ID="btnUpdate" Text="Update" runat="server" CssClass="btnImage" OnClick="btnUpdate_Click" /&gt;&lt;/div&gt;
      &lt;/div&gt;
  </code></pre>