訪問圖像我已經在GridView如下:爲什麼我無法從代碼隱藏
<asp:GridView ShowHeaderWhenEmpty="false" AlternatingRowStyle-BackColor="#EBE9E9" AutoGenerateColumns="false" OnSorting="yourTasksGV_Sorting" AllowSorting="true" ID="yourTasksGV" runat="server" ClientIDMode="Static" EmptyDataText="You currently have no tasks assigned to you" OnRowDataBound="yourTasksGV_RowDataBound" OnRowCreated="yourTasksGV_RowCreated">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Image ID="imgExpCol" AlternateText="plus" ClientIDMode="Static" ImageUrl="~/theImages/subTaskPlus.png" runat="server" CssClass="imgExpCol" />
<asp:Panel ID="pnlSubTasks" runat="server" CssClass="pnlSubTasks" ClientIDMode="Static">
<asp:GridView ID="gvSubTasks" runat="server" AutoGenerateColumns="false" ClientIDMode="Static">
<Columns>
<asp:BoundField DataField="Task Name" HeaderText="Task Name" />
<asp:BoundField DataField="Due Date" HeaderText="Due Date" />
</Columns>
</asp:GridView>
</asp:Panel>
</ItemTemplate>
</asp:TemplateField>
<asp:HyperLinkField Target="_self" DataNavigateUrlFields="Task Detail" DataTextField="Task Name" DataNavigateUrlFormatString="" HeaderText="Task Detail" SortExpression="Task Name" ItemStyle-CssClass="taskTableColumn" />
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ImageUrl="~/theImages/Dependencies.png" CssClass="gvTaskDep btnShowDepend" runat="server" ID="btnShowDepend" OnCommand="btnShowDepend_Command" CommandName="TaskDepend" AlternateText='<%#Eval("Object") + "," + Eval("FK") %>' CommandArgument='<%#Eval("Object") + "," + Eval("FK") %>' ToolTip="Click to view Dependencies" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Service" HeaderText="Service" SortExpression="Service" ItemStyle-CssClass="taskTableColumn" />
<asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" ItemStyle-CssClass="taskTableColumn" />
<asp:BoundField DataField="Due Date" HeaderText="Due" SortExpression="Due Date" ItemStyle-CssClass="taskTableColumn" />
<asp:BoundField DataField="Owner" HeaderText="Owner" SortExpression="Owner" ItemStyle-CssClass="taskTableColumn" />
<asp:BoundField DataField="Client" HeaderText="Client" SortExpression="Client" ItemStyle-CssClass="taskTableColumn" />
<asp:BoundField DataField="Site" HeaderText="Site" SortExpression="Site" ItemStyle-CssClass="taskTableColumn" />
<asp:BoundField DataField="Practice" HeaderText="Practice" SortExpression="Practice" ItemStyle-CssClass="taskTableColumn" />
<asp:BoundField DataField="Provider" HeaderText="Provider" SortExpression="Provider" ItemStyle-CssClass="taskTableColumn" />
<asp:BoundField DataField="Roles" HeaderText="Roles" SortExpression="Roles" ItemStyle-CssClass="taskTableColumn" />
<asp:BoundField DataField="Object" HeaderText="Object" SortExpression="Object" ItemStyle-CssClass="hideTag" HeaderStyle-CssClass="hideTag" />
<asp:BoundField DataField="FK" HeaderText="FK" SortExpression="Object" ItemStyle-CssClass="hideTag" HeaderStyle-CssClass="hideTag" />
</Columns>
</asp:GridView>
當我嘗試從代碼隱藏imgExpCol
,它不能找到它。
如何解決該問題?
你是如何試圖訪問?在哪個事件? – 2014-09-10 13:18:01
請顯示您的事件處理程序代碼。 – 2014-09-10 13:19:27
'imgExpCol'是在Item Template內部創建的,意思是在頁面上可能有多個該控件的實例。你期望它參考哪一個?或者你是否發現它與引發事件的控制相關? – Basic 2014-09-10 13:19:46