我在這個gridview上有一個gridview
和一個linkbutton
。在Rowcommand觸發之前GridView中LinkButton的確認框
當點擊LinkButton的,rowCommand
火災,但是我要問用戶comfirm點擊與comfirmation箱,
- 如果是 - > rowCommand火災,
- 如果NO->沒有任何反應。
我找不到方法。
我在這個gridview上有一個gridview
和一個linkbutton
。在Rowcommand觸發之前GridView中LinkButton的確認框
當點擊LinkButton的,rowCommand
火災,但是我要問用戶comfirm點擊與comfirmation箱,
我找不到方法。
添加爲LinkButton的OnClientClick
屬性:
OnClientClick="return confirm('Do you really want?');"
嘗試。
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton del = e.Row.Cells[2].Controls[0] as LinkButton;
del.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this role?');");
}
,並在我的標記:
if (e.Row.RowType == DataControlRowType.DataRow){
LinkButton link = (LinkButton)e.Row.FindControl("LinkButton1");
link .Attributes.Add("onclick", "return confirm('Are you sure to proceed with this
action?');");
}
<asp:GridView
ID="GridViewRoles"
runat="server"
Width="350px"
EmptyDataText="No Roles"
AutoGenerateColumns="False"
AllowPaging="False"
PageSize="50"
AllowSorting="True"
CssClass="gridview"
AlternatingRowStyle-CssClass="even"
OnRowCommand="GridViewRoles_RowCommand"
OnRowDataBound="GridViewRoles_RowDataBound"
OnRowDeleting="GridViewRoles_RowDeleting" OnRowEditing="GridViewRoles_RowEditing">
<Columns>
<asp:BoundField DataField="Role" HeaderText="Role" SortExpression="Role" HeaderStyle-Width="170px" HeaderStyle-HorizontalAlign="Left" />
<asp:ButtonField CommandName="Edit" Text="Edit" HeaderStyle-Width="50px" />
<asp:CommandField ShowDeleteButton="True" />
</Columns>
<AlternatingRowStyle CssClass="even" />
</asp:GridView>