我有一个数据网格,其中每一行都有公司员工的信息。我想让每行都能显示/隐藏额外的信息。我的第一个想法是使用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>这工作得很好,但它的计算代价可能很高。额外信息面板有许多文本框/标签,所有这些文本框/标签都从数据库中获取其值。每次页面加载时,所有数据都是在开始时从数据库获得的,其中一些数据是隐藏的。
有没有更好的方法来实现我的目标?或者,是否有一种方法可以在单击Show/Hide按钮时仅加载员工的额外详细信息?
提前感谢!
发布于 2010-04-10 02:18:34
我做过类似的事情,但是用的是ModalPopupExtender。我有一个带有文本框和标签的面板,只有当用户按下图像按钮时才能检索信息。在本例中,imagebutton在行中,检索数据的键在GridViewRow的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();希望这能有所帮助。克劳迪娅
https://stackoverflow.com/questions/2608443
复制相似问题