2
我在我的轉發器中有一個鏈接按鈕.. lnkEdit和lnkDelete ..我的問題是我如何分配選定的值並刪除它?如何使用linkbutton獲取中繼器中選定的值?
這裏是我的代碼:
protected void rptrInsurance_ItemCommand(object source, RepeaterCommandEventArgs e)
{
try
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
switch (e.CommandName)
{
case "Delete":
{
HCSInsurance oInsuranceDelete = new HCSInsurance();
Insurance oInsurance = new Insurance();
// oInsurance.InsuranceCode.ID = "2";
oInsuranceDelete.DeleteInsurance(oInsurance);
}
break;
case "Edit":
{
}
break;
default:
{
}
break;
}
}
}
catch (Exception ex)
{
}
}
asp.net
<asp:LinkButton ID="lnkEdit" runat="server" onclick="lnkEdit_Click" CommandName="Edit">Edit</asp:LinkButton> <asp:LinkButton
ID="lnkDelete" runat="server" onclick="lnkDelete_Click" CommandName="Delete" OnClientClick="if (!confirm('Are you sure do you want to delelte it?')) return false;">Delete</asp:LinkButton>
</td>
我更新了我的代碼以上..請檢查它 – 2011-04-25 07:07:58
感謝您的代碼。非常有幫助。 – 2017-04-22 11:34:50