我有5个div标签,在每个div标签中我都有转发器控制。如果他想要我想允许用户更新信息。所以在表单加载时,我从表中检索所有信息,因此可以更新信息。但我无法做到这一点。我正在给3个转发器控制的代码。我在按钮更新点击时尝试了这个。问题是,当我点击更新按钮时,它不是循环通过前4个转发器的每个循环,它只是循环通过每个循环的最后一个。我已经创建了存储过程以更新信息。所以,我想将所有参数发送给它,如:
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";
}
因为它循环遍历每个循环的最后一个,我在程序中得到错误,因为它没有得到它的所有参数。我在前4个转发器控制循环中定义的变量,得到空值。所以我想知道我是怎么做的可以在所有转发器控件中获取信息,因此我可以更新它。给我任何解决方案。谢谢提前。
网页表单的设计代码: 高度: '宽度=“150px”> 4.10 4.11 5 5.1 5.2 5.3 5.4 5.5
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Weight
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtWeight" runat="server" Text='<%#Eval("wt") %>' Width="150px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Skin Color:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtSkinColor" runat="server" Text='<%#Eval("skincolor")%>' Width="150px"></asp:TextBox>
<asp:DropDownList ID="drpSkinColor" runat="server" Height="24px" Width="100px" Visible="false">
<asp:ListItem>Wheatish</asp:ListItem>
<asp:ListItem>Fair</asp:ListItem>
<asp:ListItem>Tan/Brown</asp:ListItem>
<asp:ListItem>Dark</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Eye Sight:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtEyeSight" runat="server" Text='<%#Eval("eyesight")%>' Width="150px"></asp:TextBox>
<asp:DropDownList ID="drpEyeSight" runat="server" Height="24px" Width="100px" Visible="false">
<asp:ListItem>Clear</asp:ListItem>
<asp:ListItem>Glasses</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table></FooterTemplate>
</asp:Repeater>
</div>
<div id="aboutMe" runat="server" visible="false" style="margin-left: 50px; display: block">
<asp:Repeater ID="repAbootMe" runat="server" OnItemDataBound="myAboutMe">
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td class="directorytdWidth">
About Me:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtAboutMe" runat="server" Text='<%#Eval("aboutMe")%>' Width="200px"
TextMode="MultiLine" Height="100px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Active Friendship Zone:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtActiveFrndZone" runat="server" Text='<%#Eval("friendship")%>'
Width="100px"></asp:TextBox>
<asp:CheckBox ID="chkActivateFriendship" runat="server" Text="Activate My Friendship Zone Profile"
Checked="True" ForeColor="#000000" Visible="false" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table></FooterTemplate>
</asp:Repeater>
<div id="otherInfo" runat="server" visible="false" style="margin-left: 50px; display: block">
<asp:Repeater ID="repOtherInfo" runat="server" OnItemDataBound="myOtherInfo">
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td class="directorytdWidth">
Diet:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtDiet" runat="server" Text='<%#Eval("diet")%>' Width="150px"></asp:TextBox>
<asp:DropDownList ID="drpDiet" runat="server" Height="24px" Width="100px" Visible="false">
<asp:ListItem></asp:ListItem>
<asp:ListItem>Veg</asp:ListItem>
<asp:ListItem>Non-Veg</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Drink:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtDrink" runat="server" Text='<%#Eval("drink")%>' Width="150px"></asp:TextBox>
<asp:DropDownList ID="drpDrinks" runat="server" Height="24px" Width="100px" Visible="false">
<asp:ListItem></asp:ListItem>
<asp:ListItem>Don't Drink</asp:ListItem>
<asp:ListItem>Drink Socially</asp:ListItem>
<asp:ListItem>Drink like fish</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Smoke:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtSmoke" runat="server" Text='<%#Eval("smoke")%>' Width="150px"></asp:TextBox>
<asp:DropDownList ID="drpSmoking" runat="server" Height="24px" Width="100px" Visible="false">
<asp:ListItem></asp:ListItem>
<asp:ListItem>Don't Smoke</asp:ListItem>
<asp:ListItem>Smoke Socially</asp:ListItem>
<asp:ListItem>Smoker</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Drugs:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtDrug" runat="server" Text='<%#Eval("drug")%>' Width="150px"></asp:TextBox>
<asp:DropDownList ID="drpDrug" runat="server" Height="24px" Width="100px" Visible="false">
<asp:ListItem></asp:ListItem>
<asp:ListItem>No Drugs</asp:ListItem>
<asp:ListItem>Druggi</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table></FooterTemplate>
</asp:Repeater>
</div>
<div id="contactInfo" runat="server" visible="false" style="margin-left: 50px; display: block">
<asp:Repeater ID="repContactInfo" runat="server" OnItemDataBound="myContactInfo">
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td class="directorytdWidth">
First Name:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtFirstName" runat="server" Width="150px" Text='<%#Eval("firstName")%>'></asp:TextBox>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Last Name:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtLastName" runat="server" Width="150px" Text='<%#Eval("lastName")%>'></asp:TextBox>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Gender:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtGender" runat="server" Width="100px" Text='<%#Eval("gender")%>'></asp:TextBox>
<asp:RadioButtonList ID="radioGender" runat="server" RepeatColumns="2" Visible="false">
<asp:ListItem Text="Male" Value="M"></asp:ListItem>
<asp:ListItem Text="Female" Value="F"> </asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Address:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtAdd" runat="server" Width="200px" Text='<%#Eval("candiAddress")%>'
TextMode="MultiLine" Height="75px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Country:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtCountry" runat="server" Width="150px" Text='<%#Eval("countryName")%>'></asp:TextBox>
<asp:DropDownList ID="drpCountry" runat="server" Width="150px" Height="24px" Visible="false"
AutoPostBack="true" OnSelectedIndexChanged="drpCountry_SelectedIndexChanged">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="directorytdWidth">
State:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtState" runat="server" Width="150px" Text='<%#Eval("stateName")%>'></asp:TextBox>
<asp:DropDownList ID="drpState" runat="server" Width="150px" Visible="false" Height="24px"
AutoPostBack="true" OnSelectedIndexChanged="drpState_SelectedIndexChanged">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="directorytdWidth">
City:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtCity" runat="server" Width="150px" Text='<%#Eval("cityName")%>'></asp:TextBox>
<asp:DropDownList ID="drpCity" runat="server" Width="150px" Height="24px" Visible="false"
AutoPostBack="true">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Postal Code:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtPostalCode" runat="server" Width="150px" Text='<%#Eval("pincode")%>'></asp:TextBox>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Landline:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtLandline" runat="server" Width="150px" Text='<%#Eval("landline")%>'></asp:TextBox>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Mobile Number:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtMobile" runat="server" Width="150px" Text='<%#Eval("mobile")%>'></asp:TextBox>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Date of Birth:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtDob" runat="server" Width="150px" Text='<%#Eval("dob")%>'></asp:TextBox>
<asp:DropDownList ID="drpYear" runat="server" Visible="false" Height="24px" Width="80px"
AutoPostBack="true">
</asp:DropDownList>
<asp:DropDownList ID="drpMonth" runat="server" Height="24px" Width="80px" OnSelectedIndexChanged="drpMonth_SelectedIndexChanged"
AutoPostBack="true" Visible="false">
<asp:ListItem Value="1" Selected="True">January</asp:ListItem>
<asp:ListItem Value="2">February</asp:ListItem>
<asp:ListItem Value="3">March</asp:ListItem>
<asp:ListItem Value="4">April</asp:ListItem>
<asp:ListItem Value="5">May</asp:ListItem>
<asp:ListItem Value="6">June</asp:ListItem>
<asp:ListItem Value="7">July</asp:ListItem>
<asp:ListItem Value="8">August</asp:ListItem>
<asp:ListItem Value="9">September</asp:ListItem>
<asp:ListItem Value="10">October</asp:ListItem>
<asp:ListItem Value="11">November</asp:ListItem>
<asp:ListItem Value="12">December</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="drpDate" runat="server" Height="24px" Width="50px" Visible="false"
AutoPostBack="true">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="directorytdWidth">
Email Address:
</td>
<td class="directoryTdPadding">
<asp:TextBox ID="txtEmail" runat="server" Width="150px" Text='<%#Eval("altEmail")%>'></asp:TextBox>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table></FooterTemplate>
</asp:Repeater>
</div>
<div style="text-align: center">
<asp:Button ID="btnUpdate" Text="Update" runat="server" CssClass="btnImage" OnClick="btnUpdate_Click" /></div>
</div>