我有一个带有链接按钮的网格视图,当您单击它时会出现一个模态弹出窗口,其中单击了该行的详细信息。如果gridview不在更新面板中,这可以正常工作。我必须每秒更新gridview。如果我使用更新面板,则“模态弹出窗口”显示为空白。有关如何在更新面板中使用它的任何想法吗?
<div class="Info">
<asp:UpdatePanel ID="UpdatePanelMain" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="gvMain" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None"
Width="688px" AllowPaging="True" AutoGenerateColumns="false" OnSelectedIndexChanged="gvMain_SelectedIndexChanged"
Font-Size="14px" PageSize="8" DataKeyNames="TicketId, TicketNumber"
OnRowCommand="gvMain_RowCommand" OnPageIndexChanging="gvMain_PageIndexChanging"
OnRowDataBound="gvMain_RowDataBound">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="TicketId" HeaderText="Id" SortExpression="TicketId"
Visible="false">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="TicketNumber" HeaderText="Ticket #Id" SortExpression="TicketNumber"
Visible="false">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="DisplayNum" HeaderText="Ticket Number" SortExpression="DisplayNum">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lbTicketInfo" runat="server" CommandName="Popup" OnClick="lblTicketInfo_Click">LinkButton</asp:LinkButton>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="TimerGVMain" />
</Triggers>
</asp:UpdatePanel>
<asp:Timer ID="TimerGVMain" Interval="1000" runat="server" OnTick="TimerGVMain_Tick">
</asp:Timer>
<%--Used for modal popup--%>
<asp:Button ID="btnTarget" runat="server" Style="display: none;" />
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnTarget"
PopupControlID="Div1" DropShadow="True" CancelControlID="btnCloseModal" Drag="True">
</asp:ModalPopupExtender>
<div id="Div1" runat="server" style="background-color: #5D7B9D; color: White; border: #284775 3px solid;
width: 300px; height: 150px; font-size: 10pt; font-family: Verdana;">
<asp:Label ID="Label2" runat="server" Text=""></asp:Label>
<asp:GridView ID="gvTicketInfo" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None"
AutoGenerateColumns="False">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:BoundField DataField="Desc" HeaderText="Trans Type" SortExpression="Desc" />
<asp:BoundField DataField="Time" HeaderText="Est Trans Time" SortExpression="Time" />
</Columns>
</asp:GridView>
<%--Button used to close Modal Pop up--%>
<asp:Button ID="btnCloseModal" runat="server" Text="Close" />
</div>
aspx.cs
protected void gvMain_RowCommand(object sender, GridViewCommandEventArgs e)
{
RowIndex = Convert.ToInt32(e.CommandArgument);
if (e.CommandName == "Popup" && e.CommandArgument != null)
{
string displayNo = gvMain.Rows[RowIndex].Cells[3].Text;
//string displayNo = gvMain.DataKeyNames[RowIndex]["DisplayNum"].ToString();
ModalPopupExtender1.Show();
try
{
using (SqlConnection cs = new SqlConnection(connStr))
{
SqlDataAdapter da = new SqlDataAdapter("spClerkUI_ShowAllTrans_inTicket", cs);
da.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure;
da.SelectCommand.Parameters.AddWithValue("@Location", qStatic);
da.SelectCommand.Parameters.AddWithValue("@DisplayNum", displayNo);
DataSet ds = new DataSet();
da.Fill(ds);
gvTicketInfo.DataSource = ds;
gvTicketInfo.DataBind();
Label1.Text = string.Format("<Br>Row # {0}", RowIndex);
}
}
catch (Exception ex)
{
lblStatus.Text = "Modal Error: " + ex.ToString();
}
}
}
protected void gvMain_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton ImageButtonTicketInfo = (LinkButton)e.Row.FindControl("lbTicketInfo");
ImageButtonTicketInfo.CommandArgument = e.Row.RowIndex.ToString();
}
}
答案 0 :(得分:0)
在Page目录
之后添加<%@ Register TagPrefix="ajaxToolkit" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit" %>
将ModalPopupExtender1.Show();
放在try块
并添加
Div1.Visible = true;
gvTicketInfo.Visible = true;
答案 1 :(得分:0)
我认为计时器需要在更新面板中