I'm trying to update multiple checked rows in DataList.
My aspx page:
<asp:DataList ID="DLSearchResultsReps" runat="server" RepeatLayout="Flow" RepeatDirection="Horizontal" ClientIDMode="Static">
<ItemTemplate>
<tr class="<%# DateTime.Parse(Eval("Date").ToString()) < DateTime.Today.AddDays(-GlobalFunctions.RepsLongTime) ? "red lighten-4" : " " %>">
<td width="15%"><%# Eval("RepId") %></td>
<td width="10%" class="red-text"><b><%# Eval("Envelop") %></b></td>
<td width="15%"><%# Eval("Date") %></td>
<td width="20%"><%# Eval("CustomerFirst") %> <%# Eval("CustomerLast") %></td>
<td width="20%"><%# Eval("Product") %></td>
<td width="15%"><%# Eval("Status") %></td>
<td width="5%">
<asp:CheckBox ID="cbCheckedRep" runat="server" DataKeyField ='<%# Eval("RepId") %>' />
<input type="hidden" id="HiddenRepId" value="<%# Eval("RepId") %>" />
</td>
</tr>
</ItemTemplate>
</asp:DataList>
My code behind:
protected void UpdateMultiple_Click(object sender, EventArgs e)
{
foreach (DataListItem objitem in DLSearchResultsReps.Items)
{
HtmlInputCheckBox cbCheckedRep = objitem.FindControl("cbCheckedRep") as HtmlInputCheckBox;
if (cbCheckedRep != null)
{
if (cbCheckedRep.Checked == true)
{
HiddenField hd = (HiddenField)objitem.FindControl("HiddenRepId");
GlobalFunctions.ChangeRepStatus(hd.Value, int.Parse(dlStatus.SelectedValue));
}
}
}
}
if (cbCheckedRep.Checked) is always FALSE.
Thanks.
Aucun commentaire:
Enregistrer un commentaire