c# - Why am I not able to access an image from code-behind -
i have following gridview:
<asp:gridview showheaderwhenempty="false" alternatingrowstyle-backcolor="#ebe9e9" autogeneratecolumns="false" onsorting="yourtasksgv_sorting" allowsorting="true" id="yourtasksgv" runat="server" clientidmode="static" emptydatatext="you have no tasks assigned 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 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>
when try access imgexpcol
code-behind, cannot find it.
how resolve issue?
as kidbilly says, cannot access them directly. also, aware ids mangled @ runtime since not permitted have multiple ids same on single page (i.e. 1 button each row of gridview), in case, need see how mangled before know pass findcontrol().
for instance, have linkbutton id="edit" , when rendered, becomes id="maincontent_loginview2_existingaccounts_edit_0"
Comments
Post a Comment