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
     }

添加更新面板和计时器控件的必要性是每5分钟自动刷新一次datalist1。请帮我解决这个问题。添加这两个控件后,链接按钮停止工作。

4

2 回答 2

0

您必须在链接按钮标签中设置 CommandArgument 和 CommandName,然后使用 Command 事件而不是 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>

然后在代码隐藏中处理该参数.. MSDN 中的 CommandArgument

于 2014-04-24T05:28:47.287 回答
0

尝试这个..

<Triggers>
     <asp:AsyncPostBackTrigger ControlID="btnView"/>  
</Triggers>
于 2014-04-24T05:23:29.110 回答