0
        <asp:ScriptManager ID="ScriptManager1" runat="server">                                  
    </asp:ScriptManager<asp:UpdatePanel ID="UpdatePanel1"runat="server">
    <ContentTemplate>
    <asp:Timer runat="server" ID="Timer2"   Interval="60" ontick="Timer1_Tick"/>
    <asp:DataList ID="DataList1" runat="server" RepeatColumns="1" onitemcommand="DataList1_ItemCommand">
    <ItemTemplate>
    <b>Test Name:</b> <%# DataBinder.Eval(Container.DataItem, "Name")%> <br />
    <b>Test Phone:</b> <%# DataBinder.Eval(Container.DataItem, "Phone")%> <br />
    <asp:LinkButton ID="btnView" runat="server" Text="View" CommandName="ShowDetails" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "Name")%>' OnCommand="btnView_Command"></asp:LinkButton>
    </ItemTemplate>
    </asp:DataList>
    </ContentTemplate>
    <Triggers>
    <asp:AsyncPostBackTrigger ControlID="Timer1"     EventName="Tick" />
    </Triggers>
    </asp:UpdatePanel>
    <asp:Panel ID="panel2" runat="server" Visible="false"></asp:Panel>
Code Behind :


    protected void dlBundleRequests_ItemCommand(object source, DataListCommandEventArgs e)
    {
        panel1.Visible = false;
        panel2.Visible = true;

        if (e.CommandName == "ShowDetails")// null)
        {
            Session["Name"] = e.CommandArgument.ToString();
            //Show Panel2
        }
    }
    protected void Timer1_Tick(object sender, EventArgs e)
    {
         //Binding DataList1
    }
    protected void btnView_Command(Object sender, CommandEventArgs e)
    {
      //set visibility true for Panel2
     }

The necessity of adding updatepanel & timer control is to autorefresh the datalist1 for every 5 minutes.Please help me out of this.After adding these two controls ,link button stops working.

Lalita
  • 153
  • 2
  • 4
  • 16

2 Answers2

0

Try this..

<Triggers>
     <asp:AsyncPostBackTrigger ControlID="btnView"/>  
</Triggers>
Jameem
  • 1,840
  • 3
  • 15
  • 26
  • Giving me the error: A control with ID 'btnView' could not be found for the trigger in UpdatePanel 'upBundleReq'. But 'btnView' is exists in the aspx page. – Lalita Apr 24 '14 at 05:57
0

you must set CommandArgument and CommandName in linkbutton tag, then use Command event not Click

    <ItemTemplate>
            <b>Test Name:</b> <%# DataBinder.Eval(Container.DataItem, "Name")%> <br />
            <b>Test Phone:</b> <%# DataBinder.Eval(Container.DataItem, "Phone")%> <br />
                <asp:LinkButton ID="btnView" runat="server" Text="View" OnCommand="btnView_Click" CommandName="ShowDetails" CommandArgument='%# DataBinder.Eval(Container.DataItem, "Phone")%' ></asp:LinkButton>
</ItemTemplate>

then handle that argument in codebehind.. CommandArgument in MSDN

warrior
  • 61
  • 1
  • 3
  • 11
  • :I hav tried this,while debugging it is firing the event.But in UI it is not displaying anything.Error msg is:The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled..I hav tried in IE – Lalita May 12 '14 at 07:21
  • @user1676709 use your own code and in Timer1_Tick set interval to 50000 to tick every 5 minute. with this change on every page load your panel has updated, and updated automatically every 5 minute... – warrior May 12 '14 at 07:59
  • @user1676709 onclick evnet doesn't work because your page/panel is loading/refreshing immediately ... – warrior May 12 '14 at 08:06
  • ItemCommand event of datalist am placing the code which has to execute on ONCLICK of view button,not on Onclick of view btn which is inside datalist control.I have totally removed Onclick event of view button – Lalita May 12 '14 at 08:47
  • :Inside datalist i hav view linkbutton.Need to refresh datalist for every 5min.after implementing refresh functionality(timer control) caught with the problm(view link button is not doing postback).So implementd the solution proposed by you.i.e instead of view button clik event,wrote code in ItemCOmmand event of datalist.so whenever user clicks on view link button,Itemcommand event will fire and executes the code related to view button.But unfortunately nothing is displaying.But code related to view button exectes while debugging – Lalita May 12 '14 at 08:53
  • @user1676709 please update your question with your's new implementation and update method ... – warrior May 12 '14 at 11:03
  • @user1676709 thats code work correctly. if u only change timer's interval to a larger value like 50000 for 5 minute. oncommand or onclick event doesn't raised because update panel is updating/refreshing immediately. see this [link](http://codepaste.net/28vd6i) – warrior May 14 '14 at 13:54
  • strange :( eventhough i have increased timer to 50000 interval,not working.View link button is not doing its job.Not showing the other panel. – Lalita May 14 '14 at 16:56
  • I have added it,while debugging the onCommand is firing but it is not displaying anything. – Lalita May 15 '14 at 05:07
  • @user1676709 because panel2 is outside of update panel and its still invisible... move panel2 into the update panel to view changes realtime - sorry for my bad english – warrior May 15 '14 at 05:35