I have a repeater that lists data including an ID that I pass to a user control that is not visible until I click a linkbutton. However, when I have clicked the linkbutton, the ID has been lost.
Anyone have any idea where I’m going wrong?
Here is the code for the repeater:
<asp:Repeater ID="uxPolicyList" runat="server" onitemdatabound="uxPolicyList_ItemDataBound">
<ItemTemplate>
<tr>
<td class="smaller-ctrl">
<img src="Assets/Images/home-icon.gif" alt="Home Insurance Policy" /><%#Eval("PolicyNumber")%>
</td>
<td>
<%#Eval("StartDate","{0:d}")%>
</td>
<td class="center-cell-ctrl">
<%#Eval("Renewal", "{0:d}")%>
</td>
<td class="center-cell-ctrl">
Postcode:<br />
<%#Eval("Postcode")%>
</td>
<td id='<%#Eval("PolicyNumber")%>' class="button-cell">
<asp:LinkButton ID="uxPolicySummaryButton" CssClass="policy-link-ctrl" CommandName="PolicyNumber" CommandArgument='<%#Eval("PolicyNumber")%>' OnCommand="uxPolicySummaryButton_Command" runat="server">Policy summary<br /></asp:LinkButton>
</td>
</tr>
<uc1:PolicySummary ID="uxPolicySummary" PolicyNumber='<%#Eval("PolicyNumber")%>' runat="server" Visible="false" />
</ItemTemplate>
I have these get/set accessors in the user control code-behind, but they’re always blank:
public string _policyNumber = string.Empty;
public string PolicyNumber
{
get
{
return _policyNumber;
}
set
{
_policyNumber = value;
}
}
When testing, I hard coded a value in the user control. i.e.
<uc1:PolicySummary ID="uxPolicySummary" PolicyNumber="545545-5454-54545" runat="server" Visible="false" />
…and it worked fine. Any ideas appreciated
try to reassign value of
PolicyNumberproperty insideOnCommandevent with the value ofCommandArgumentEdit
or save it into
HiddenFieldinside your control