0

我有一个数据网格,其中每一行都有关于公司员工的信息。我想允许每一行显示/隐藏额外信息。我的第一个想法是使用 AJAX 工具包中的 CollapsiblePanelExtender 并让每一行都像这样:

<ajaxtoolkit:collapsiblepanelextender
     TargetControlID="panel2">
     ExpandControlID="LinkButton1"
     CollapseControlID="LinkButton1">
</ajaxtoolkit:collapsiblepanelextender>

<asp:panel>
    FirstName | LastName | Phone | Email
    <LinkButton1>  <- this hides/show extra info in panel2
</asp:panel>

<asp:panel2>
     <textbox ="FirstName">
     <textbox ="LastName">
     <textbox ="EmailName">
     ...
     ...lots of textboxes where information is assigned from the database.
</asp:panel2>

这工作得很好,但它的计算成本可能很高。额外信息面板有很多文本框/标签,所有这些都从数据库中获取其值。每次页面加载时,所有数据都是从数据库中获取的,其中一些是隐藏的。

有没有更好的方法来实现我的目标?或者有没有办法只在单击显示/隐藏按钮时加载员工的额外详细信息?

提前致谢!

4

1 回答 1

1

我做过类似的事情,但使用了 ModalPopupExtender。我有一个带有文本框和标签的面板,只有当用户按下图像按钮时才会检索信息。在此示例中,图像按钮位于 GridViewRow 中,用于检索数据的键位于 Row 的 DataKeys 属性中。

GridViewRow row = ((GridViewRow)((ImageButton)sender).NamingContainer);
//NamingContainer return the container that the control sits in
DataKey key = ((GridView)row.NamingContainer).DataKeys[row.RowIndex];

//Retrieve data with a server method. It can be with wathever you want, I use an ArrayList
ArrayList AL=Domain.GetCustomerData(key[0].ToString());

//Fill controls with data, 
LblDate.Text = AL[0].ToString();
dLectHidro.Value = AL[1].ToString();
idLectHL.Value = AL[2].ToString();
LblEstacion.Text = HttpUtility.HtmlDecode(AL[3].ToString());
TxtLluvia.Text = HttpUtility.HtmlDecode(AL[4].ToString());
TxtLluvia1.Text = HttpUtility.HtmlDecode(AL[5].ToString());

//Show the popup
this.ModalPopupModif.Show();

希望这可以帮助。克劳迪娅

于 2010-04-09T18:18:33.950 回答