Repeater
「メンバーシップの変更」というラベルの付いたリンクを含む があります。これをクリックすると、 と のライトボックスが開きradiobuttonlist
ますbutton
。ライトボックスのボタンがクリックされると、最初にラジオボタン リストの選択された値を見つける必要があるコールバック イベントが発生します。これがリピーターです。
<script language="JavaScript" type="text/javascript">
function CreateBox(id) {
$(document).ready(function () {
$("#lnk" + id).fancybox({
'closeBtn': true,
helpers: {
overlay: { closeClick: false }
}
});
});
}
</script>
頭
体
<asp:Repeater ID="repProspects" runat="server" OnItemDataBound="repProspects_ItemDataBound">
<ItemTemplate>
<asp:HiddenField ID="hfRequestID" runat="server" Value='<%# DataBinder.Eval(Container, "DataItem.RequestID") %>' />
<asp:HiddenField ID="hfRecruiterNumber" runat="server" Value='<%# DataBinder.Eval(Container, "DataItem.RecruiterCardNumber") %>' />
<asp:HiddenField ID="hfCompanyID" runat="server" Value='<%# DataBinder.Eval(Container, "DataItem.CompanyID") %>' />
<asp:HiddenField ID="hfMemberType" runat="server" Value='<%# DataBinder.Eval(Container, "DataItem.MemberType") %>' />
<asp:HiddenField ID="hfLifeDuesAmount" runat="server" Value='<%# DataBinder.Eval(Container, "DataItem.Dues") %>' />
<asp:HiddenField ID="hfDerivedAnnualDues" runat="server" />
<asp:HiddenField ID="hfDerivedInstallments" runat="server" />
<asp:HiddenField ID="hfRblSelectedValue" runat="server" />
<asp:HiddenField ID="hfSetMemberType" ClientIDMode="Static" runat="server" />
<asp:HiddenField ID="hfState" runat="server" Value='<%# DataBinder.Eval(Container, "DataItem.HomeState") %>' />
<asp:HiddenField ID="hfCountry" runat="server" Value='<%# DataBinder.Eval(Container, "DataItem.HomeCountry") %>' />
<asp:HiddenField ID="hfBirthday" runat="server" Value='<%# DataBinder.Eval(Container, "DataItem.Birthday") %>' />
<div id='h<%# DataBinder.Eval(Container, "DataItem.ID") %>' class="header" onclick='ToggleDisplay(<%# DataBinder.Eval(Container, "DataItem.ID") %>);'>
<img id="img<%# DataBinder.Eval(Container, "DataItem.ID") %>" alt="" src="../images/plusIconSmaller.png" />
<%# DataBinder.Eval(Container, "DataItem.FirstName")%>
<% if (DataBinder.GetDataItem("DataItem.MiddleName") != "")
{ %>
<%# DataBinder.Eval(Container, "DataItem.MiddleName")%>
<% } %>
<%# DataBinder.Eval(Container, "DataItem.LastName")%>
<% if (DataBinder.GetDataItem("DataItem.Suffix") != "")
{ %>
<%# DataBinder.Eval(Container, "DataItem.Suffix")%>
<% } %>
(<%# DataBinder.Eval(Container, "DataItem.CurrentStatus")%>, <%# DataBinder.Eval(Container, "DataItem.BranchOfService")%>)
<asp:Label ID="lblRecruitedBy" runat="server"></asp:Label>
<%# Convert.ToDateTime(DataBinder.Eval(Container, "DataItem.DateCreated")).ToShortDateString()%>
</div>
<div id='reqid<%# DataBinder.Eval(Container, "DataItem.RequestID") %>'></div>
<div id='d<%# DataBinder.Eval(Container, "DataItem.ID") %>' class="details">
<table width="100%">
<tr>
<td valign="top" width="25%"><u><b>Address</b></u><br />
<%# DataBinder.Eval(Container, "DataItem.HomeAddressLine1")%><br />
<%# DataBinder.Eval(Container, "DataItem.HomeCity")%>, <%# DataBinder.Eval(Container, "DataItem.HomeState")%> <%# DataBinder.Eval(Container, "DataItem.HomeZipCode")%><br />
<%# DataBinder.Eval(Container, "DataItem.HomeCountry")%></td>
<td valign="top" width="20%"><u><b>Qualifying Service</b></u><br />
<asp:Label ID="lblServiceInfo" runat="server"></asp:Label></td>
<td valign="top" width="20%"><u><b>Contact Info</b></u><br />
<% if (DataBinder.GetDataItem("DataItem.Phone") != "")
{ %>
<%# FormatPhone(DataBinder.Eval(Container, "DataItem.Phone").ToString()) %>
<% } %>
<asp:Label ID="lblMemberPhone" runat="server"></asp:Label>
<%# DataBinder.Eval(Container, "DataItem.Email")%><br />
Birthday: <%# Convert.ToDateTime(DataBinder.Eval(Container, "DataItem.Birthday")).ToShortDateString()%></td>
<td valign="top" width="20%"><u><b>Membership</b></u><br />
<%# DataBinder.Eval(Container, "DataItem.MemberType")%><br />
$<asp:Label ID="lblDuesAmount" runat="server"></asp:Label>
<br />
<a href='#ChgMemType<%# DataBinder.Eval(Container, "DataItem.ID") %>' onclick='CreateBox(<%# DataBinder.Eval(Container, "DataItem.ID") %>);' id='lnk<%# DataBinder.Eval(Container, "DataItem.ID") %>' >Change Membership</a>
</td>
<td valign="top" align="center">
<asp:Button ID="lnkApprove" Style="border: 1px solid black; border-radius: 7px; padding: 5px; cursor: pointer; background-color: #990000; width: 130px; color: white; font-weight: bold" Text="Approve & Pay" runat="server" CommandArgument='<%# DataBinder.Eval(Container, "DataItem.ID") %>' OnClientClick="return confirm('Are you sure you want to approve this member application?');" OnCommand="lnkApprove_Click"></asp:Button><br />
<br />
<asp:Button ID="lnkReject" Style="border: 1px solid black; border-radius: 7px; padding: 5px; cursor: pointer; background-color: #990000; width: 130px; color: white; font-weight: bold" Text="Reject" runat="server" CommandArgument='<%# DataBinder.Eval(Container, "DataItem.ID") %>' OnClientClick="return confirm('Are you sure you want to reject this member applictation?');" OnCommand="lnkReject_Click"></asp:Button></td>
</tr>
</table>
</div>
<div id='ChgMemType<%# DataBinder.Eval(Container, "DataItem.ID") %>' style="display: none; width:400px; text-align: left">
<h3>Change Membership Type </h3>
<p>Please select the membership type below:</p>
<input id='hfChangedMemberType' value="<%# DataBinder.Eval(Container, "DataItem.ID") %>" type="hidden" />
<div id="RadioDiv">
<asp:RadioButtonList ID="_rblMemberTypes" runat="server">
<asp:ListItem Text="Annual" Value="Annual">Annual</asp:ListItem>
<asp:ListItem Text="Life" Value="Life">Life</asp:ListItem>
<asp:ListItem Text="Installment" Value="Installment">Installment</asp:ListItem>
</asp:RadioButtonList>
</div>
<asp:LinkButton ID="lbSetMemType" EnableViewState="true" CommandArgument='<%# DataBinder.Eval(Container, "DataItem.RequestID") %>' OnCommand="lbSetMemType_Command" CssClass="button" runat="server">Save</asp:LinkButton>
</div>
</ItemTemplate>
</asp:Repeater>
次は、[保存] ボタンがクリックされたときのコード ビハインド イベントです。
protected void lbSetMemType_Command(object sender, CommandEventArgs e)
{
decimal dDuesAmount = 0;
bool bSuccess = false;
int iRequestID = Convert.ToInt32(e.CommandArgument);
string sMemType = "";
HiddenField hfDerivedAnnualDues;
HiddenField hfDerivedInstallments;
HiddenField hfLifeDuesAmount;
HiddenField hfSetMemberType;
foreach (RepeaterItem item in repProspects.Items)
{
// Checking the item is a data item
if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
{
var reqid = item.FindControl("hfRequestID") as HiddenField;
if (Convert.ToInt32(reqid.Value) == iRequestID) {
var rdbList = item.FindControl("_rblMemberTypes") as RadioButtonList;
if (rdbList != null)
{
foreach (ListItem li in rdbList.Items)
{
if (li.Selected == true)
{
sMemType = li.Text;
}
}
}
// Get the selected value
hfSetMemberType = item.FindControl("hfRblSelectedValue") as HiddenField;
sMemType = rdbList.SelectedValue;
// sMemType = hfSetMemberType.Value;
hfDerivedAnnualDues = item.FindControl("hfDerivedAnnualDues") as HiddenField;
hfDerivedInstallments = item.FindControl("hfDerivedInstallments") as HiddenField;
hfLifeDuesAmount = item.FindControl("hfLifeDuesAmount") as HiddenField;
}
}
}
switch (sMemType)
{
case "Annual":
{
//dDuesAmount = Convert.ToDecimal(hfDerivedAnnualDues.Value);
break;
}
case "Life":
{
//dDuesAmount = Convert.ToDecimal(hfLifeDuesAmount.Value);
break;
}
case "Installments":
{
// dDuesAmount = Convert.ToDecimal(hfDerivedInstallments.Value);
break;
}
default:
{
//dDuesAmount = Convert.ToDecimal(hfDerivedAnnualDues.Value);
break;
}
}
bSuccess = logicManager.UpdateNewMemberAppMemType(iRequestID, sMemType, dDuesAmount);
}
ブレークポイントを設定でき、hiddenfields の値が正しいことを確認できますが、このステートメントで右クリックした値を取得できません。
sMemType = rdbList.SelectedValue;
初期値は取得できますが、ユーザーがクリックした値は取得できませんか?