0

我有 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 个中继器控制循环中定义的变量,获取空值。所以我想知道如何获取信息在所有中继器控件中,所以我可以更新它。给我任何解决方案。提前谢谢。

网页表单设计代码:Height: ' Width="150px"> 4.10 4.11 5.0 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>
                            &nbsp;&nbsp;
                            <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>
                            &nbsp;&nbsp;
                            <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>
4

0 回答 0