G
Guest
Hi,
I'm trying to create a page with a datalist that loads from a template the
ItemTemplate, which contains a linkbutton that should have the commandname =
"edit"
But when I click on the link button nothing happens. I tried also the
findcontrol method, without any result.
That's the template:
<asp:LinkButton ID="button1" Runat="server" Text=''
CommandName="Edit" >
<asp:Label id="Label2" runat="server"
Text='<%#DataBinder.Eval(Container, "DataItem.CPNAME"%>'>
that's the code to load the template:
DataSet _eve = loaddata();
this.DataList1.ItemTemplate = Page.LoadTemplate("templa1.ASCX");
DataList1.DataSource= _eve;
DataList1.DataBind();
then i also tried this one ::
foreach(DataListItem item in DataList1.Items)
{
LinkButton _li = new LinkButton();
_li = (LinkButton)item.FindControl("button1");
_li.Text="Hello" ; ////// HERE IS NOT WORKING , GIVES ME AN ERROR ON
REFERENCE TO OBJECT NOT SET ON AN ISTANCE
When i click on the LinkButton i should be able to call the editcommand
routine, but nothing happens, is because the template is loaded in a
different way than the control?
Thank you
Fabrizio
I'm trying to create a page with a datalist that loads from a template the
ItemTemplate, which contains a linkbutton that should have the commandname =
"edit"
But when I click on the link button nothing happens. I tried also the
findcontrol method, without any result.
That's the template:
<asp:LinkButton ID="button1" Runat="server" Text=''
CommandName="Edit" >
<asp:Label id="Label2" runat="server"
Text='<%#DataBinder.Eval(Container, "DataItem.CPNAME"%>'>
that's the code to load the template:
DataSet _eve = loaddata();
this.DataList1.ItemTemplate = Page.LoadTemplate("templa1.ASCX");
DataList1.DataSource= _eve;
DataList1.DataBind();
then i also tried this one ::
foreach(DataListItem item in DataList1.Items)
{
LinkButton _li = new LinkButton();
_li = (LinkButton)item.FindControl("button1");
_li.Text="Hello" ; ////// HERE IS NOT WORKING , GIVES ME AN ERROR ON
REFERENCE TO OBJECT NOT SET ON AN ISTANCE
When i click on the LinkButton i should be able to call the editcommand
routine, but nothing happens, is because the template is loaded in a
different way than the control?
Thank you
Fabrizio