2015-04-08 92 views
0

我有我在我的ASP.NET Web應用程序頁面中的一個問題 - computers.aspx頁面。選擇GridView控件不觸發 - ASP.NET

當點擊任何的「GridView1」記錄的選擇按鈕 - 選擇不火。我瀏覽了大約20個相關的問題,但找不到任何有用的東西。

見下面的代碼:

 <div class="table-responsive" style="border:none"> 
<asp:GridView ID="GridView1" CssClass="table" runat="server" AllowPaging="True" GridLines="None" OnSelectedIndexChanged="OnSelectedIndexChanged" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="idComputers" DataSourceID="ComputersGridview"> 
       <Columns> 
        <asp:Templatefield ShowHeader="false"> 
         <ItemTemplate> 
          <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="true" OnClick="LinkButton1_Click" commandname="select" Text="&lt;span class=&quot;glyphicon glyphicon-info-sign&quot; style=&quot;font-size:x-large;font-align:center;color:rgb(34,54,104);&quot; /&gt;"></asp:LinkButton> 
         </ItemTemplate> 
        </asp:Templatefield><asp:TemplateField ShowHeader="False"> 
         <ItemTemplate> 
          <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="true" CommandName="Select" Text="&lt;span class=&quot;glyphicon glyphicon-check&quot; style=&quot;font-size:x-large;font-align:center;color:rgb(34,54,104);&quot; /&gt;"></asp:LinkButton> 
         </ItemTemplate> 
        </asp:TemplateField> 

     <asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" /> 
     <asp:BoundField DataField="Hostname" HeaderText="Hostname" SortExpression="Hostname" /> 
     <asp:BoundField DataField="Username" HeaderText="Username" SortExpression="Username" /> 
     <asp:BoundField DataField="officename" HeaderText="Office Name" SortExpression="officename" /> 
     <asp:BoundField DataField="IPAddress" HeaderText="IP Address" SortExpression="IPAddress" /> 
     <asp:BoundField DataField="ManufacturerName" HeaderText="Manufacturer" SortExpression="ManufacturerName" /> 
     <asp:BoundField DataField="Model" HeaderText="Model" SortExpression="Model" /> 
     <asp:BoundField DataField="HDDSize" HeaderText="HDD Size" SortExpression="HDDSize" /> 
     <asp:BoundField DataField="RAMSize" HeaderText="RAM Size" SortExpression="RAMSize" /> 
    </Columns> 
        <RowStyle HorizontalAlign="Center" /> 

</asp:GridView> 
<asp:SqlDataSource ID="ComputersGridView" runat="server" ConnectionString="<%$ ConnectionStrings:ITManagementConnectionString %>" ProviderName="<%$ ConnectionStrings:ITManagementConnectionString.ProviderName %>" SelectCommand="SELECT computers.idComputers, status.Status, computers.Hostname, ingenium.person.id, ingenium.person.forename, ingenium.person.surname, CASE WHEN ingenium.person.knownas = ' ' THEN concat(ingenium.person.forename, ' ', ingenium.person.surname) ELSE ingenium.person.knownas end AS Username, office.officename, computers.IPAddress, manufacturer.ManufacturerName, model.Model, harddrive.HDDSize, ram.RAMSize, Computers.DateCreated FROM computers INNER JOIN ingenium.person ON computers.idUser = ingenium.person.id INNER JOIN status ON computers.idStatus = status.idStatus INNER JOIN office ON computers.idoffice = office.idoffice INNER JOIN manufacturer ON computers.idManufacturer = manufacturer.idManufacturer INNER JOIN model ON computers.idModel = model.idModel INNER JOIN harddrive ON computers.idHDD = harddrive.idHardDrive INNER JOIN ram ON computers.idRAM = ram.idRAM WHERE (computers.idComputerType = 1) OR (computers.idComputerType = 2) ORDER BY computers.datecreated DESC"> 
</asp:SqlDataSource> 
</div> 

這是昨天的工作 - 選擇卻突然停止了射擊。

任何幫助將不勝感激!

非常感謝,

克里斯

+0

最近是否添加一個UpdatePanel? –

+0

不,我不使用他們 –

+0

檢查你的開發人員工具控制檯 – InferOn

回答

0

嘗試在兩種設置了LinkBut​​ton到CausesValidation="False"看看問題是否與驗證。如果它像那樣工作,請檢查您的驗證參數。

+0

感謝您回覆薩米語 - 「CausesValidation =」False「」不起作用。 –

+0

您的事件處理程序不僅僅是選擇行嗎?是否有可能該行被選中,但所選行的樣式與未選中的行完全相同,因此您不會注意到它? – Sami

+0

它檢查是否選擇該行,並強調它的紅色,如果它是 - 我探討了選擇早,因爲我認爲這是唯一的問題,它則查出了選擇的問題。 –