2017-07-27 138 views
0

網格視圖鏈接按鈕(其中一列)onclick不會觸發。真的不明白是什麼做錯了。需要幫忙。菜鳥編碼。網格視圖鏈接按鈕不點擊點擊asp.net?

的.aspx

 <asp:GridView ID="gridTSRJOBList" runat="server" AutoGenerateColumns="False" CssClass="table table-striped table-bordered dataTable print-first-column-hide" CellSpacing="0" Width="100%" ShowHeaderWhenEmpty="True" EmptyDataText="No TSR JOB Found for this Lease" GridLines="None" DataKeyNames="JobID"role="grid">      
<Columns> 
<asp:TemplateField HeaderText="Job" ItemStyle-HorizontalAlign="Left"> 
<ItemTemplate> 
<asp:LinkButton runat="server" ID="lnkJobID" CommandArgument='<%# Eval("JobID") %>' Text='<%#Eval("JobID") %>' OnClick="lnkJobID_Click"></asp:LinkButton></ItemTemplate> 
</asp:TemplateField> 
<asp:BoundField DataField="CategoryID" HeaderText="Category" ReadOnly="True" /> 
<asp:BoundField DataField="JobDetail" HeaderText="Short Description" ReadOnly="True" /> 
<asp:BoundField DataField="JobType" HeaderText="Job Status" ReadOnly="True" /> 
    <asp:BoundField DataField="CustomerReference" HeaderText=" Customer Reference" ReadOnly="True" /> 
</Columns> 
</asp:GridView> 

C#代碼

protected void lnkJobID_Click(object sender, EventArgs e) 
{ 
    try { 
     LinkButton jobLinkbutton = new LinkButton(); 
     jobLinkbutton = (LinkButton)sender; 
     Response.Redirect("TSR_proc.aspx?bl=1&JOBID=" + jobLinkbutton.CommandArgument); 

    } catch (Exception ex) { 
    } 
} 
+0

你在頁面中使用updatepanel嗎? – Koderzzzz

+0

@Koderzzzz no mate –

+0

鏈接按鈕中的用戶causesvalidation =「false」 – Koderzzzz

回答

0

從LinkBut​​ton的起飛lnkJobID_Click並添加CommandName='clickLink'。 你可以在Gridview RowCommand事件中管理這個事件,在你的情況下

gridTSRJOBList_RowCommand