我正在尝试显示问题的网格视图,并且一些问题有更多详细信息可以通过单击问题编号(linkbutton)显示,并且gridview将直接显示在问题编号下的这些详细信息。 我可以使用图像而不是链接按钮,但我无法显示每个问题的图像,我必须使用行数据绑定代码打开/关闭它。这是它停止工作的时候。香港专业教育学院尝试了几件事,使用javascript作为一个函数,试图封装在div等,我被卡住了。我相信这是某个地方的javascript,但我没有想法。我愿意使用图像或超链接,只要它可以打开/关闭,并在点击时显示网格。谢谢!
后端:
Private Sub grdChanges_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles grdChanges.RowDataBound
Select Case e.Row.RowType
Case DataControlRowType.DataRow
Dim rowDat As Model.DocumentModel.DocChangeHistory = DirectCast(e.Row.DataItem, Model.DocumentModel.DocChangeHistory)
Dim lbuttonQuestionText As LinkButton = e.Row.FindControl("linkButtonQuestionNum") ' when click show detailed gridview
Dim lblQuestionText As Label = e.Row.FindControl("lblQuestionNum") 'No details available just show label
If rowDat.details_needed = 1 Then
lblQuestionText.Visible = False
lbuttonQuestionText.Visible = True
Dim QuestionId As Long = convert.ToInt64(grdChanges.DataKeys(e.Row.RowIndex).Value)
Dim gvQuestionDetails As GridView = TryCast(e.Row.FindControl("gvQuestionDetails"), GridView)
Using hDal As New HistoryDAL(CurrentUserId, ProjectID)
'grabbing information from the database works fine
gvQuestionDetails.DataSource = <blah Blah>
gvQuestionDetails.DataBind()
End Using
Else 'no details needed just show regular question number as label not linkbutton
lblQuestionText.Visible = True
lbuttonQuestionText.Visible = false
End If
ASCX:
<asp:TemplateField HeaderText="#" ItemStyle-CssClass="col-400px" ItemStyle-Width="25px" SortExpression="QuestionNum" >
<ItemTemplate>
<asp:Label ID="lblQuestionNum" Font-Bold="true" runat="server" Text='<%# Bind("question_id")%>' Visible="false" ToolTip='<%#Eval("question_text")%>'></asp:Label>
<asp:LinkButton ID="linkButtonQuestionNum" runat="server" Text='<%#Bind("question_id")%>' Visible="false" BorderStyle-Right="None" ToolTip='<%#Eval("question_text")%>' />
<asp:Panel ID="pnlTableQuestion" runat="server" Style="display: none">
<asp:GridView ID="gvQuestionDetails" runat="server" AutoGenerateColumns="false" >
<Columns>
<asp:BoundField ItemStyle-Width="150px" DataField="col_name" HeaderText="Column" />
<asp:BoundField ItemStyle-Width="150px" DataField="comments" HeaderText="Comments" />
</Columns>
</asp:GridView>
</asp:Panel>
</ItemTemplate>
</asp:TemplateField>
的javascript:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$("[src*=plus]").live("click", function () {
$(this).closest("tr").after("<tr><td></td><td colspan = '999'>" +
$(this).next().html() + "</td></tr>")
$(this).attr("src", "images/minus_Expand.jpg");
});
$("[src*=minus]").live("click", function () {
$(this).attr("src", "images/plus_Collapse.jpg");
$(this).closest("tr").next().remove();
});
</script>
答案 0 :(得分:0)
我能够在Javascript中找到修复程序。最好的例子是: