asp.net - Call method in ListView EmptyDataTemplate -



asp.net - Call method in ListView EmptyDataTemplate -

i have simple listview emptydatatemplate. in emptydatatemplate, there linkbutton visble property value look calls method in code behind. problem linkbutton visible regardless of whether method returns true or false (my method isn't beingness called set breakpoint on it). come across this? what's happening here?

e.g.

<asp:listview id="peoplelistview" runat="server" ...> ... <emptydatatemplate> sorry, no people view.<br /> <asp:linkbutton id="newbutton" runat="server" visible='<%# editpermitted() %>'>new record</asp:linkbutton> </emptydatatemplate> </asp:listview>

in code behind, have method:

protected bool editpermitted() { homecoming false; }

i don't think can set scriplets <% %> within of server controls.

you need grab rowdatabound event, , set link button's visibility there

void gridview1_rowdatabound(object sender, gridviewroweventargs e) { if (e.row.rowtype == datacontrolrowtype.emptydatarow) { linkbutton lb = e.row.findcontrol("newbutton"); lb.visible = editpermitted(); } }

asp.net listview

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -