62,267
社区成员
发帖
与我相关
我的任务
分享
protected void LinkButton1_OnClick(object sender, EventArgs e)
{
GridViewRow gvr = (sender as LinkButton).NamingContainer as GridViewRow;
if(gvr != null)
this.ClientScript.RegisterStartupScript(typeof(string), "js", "alert('行索引:"+gvr.RowIndex +"')", true);
}
<!-- 这里设置它的CommandName-->
<asp:LinkButton ID="LIKBt" runat="server" OnClick="LIKBt_Click" Text='<%# Eval("id") %>' CommandName="name" ></asp:LinkButton>
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "name")
{
LinkButton lnk = e.Item.FindControl("LIKBt") as LinkButton;
Label lbl = e.Item.FindControl("FaqID") as Label;
int strID = int.Parse(lnk.Text);
string strName = lbl.Text;
}
}
protected void LinkButton1_OnClick(object sender, EventArgs e)
{
LinkButton LinkButton1 = sender as DropDownList;
int index = (DropDownList1.NamingContainer as GridViewRow).RowIndex;
......
}