一旦gridview填充了数据,我试图用div和gridview打开一个fancybox。
我可以通过直接调用fancybox来打开fancybox,也可以在没有显示fancybox的情况下填充girdview。
这是我刚才填充girdview的代码,因为这是我需要去的地方。
任何和所有帮助都有用。
方法
Public Sub GetEmailContacts()
Session("RoleCode") = 27
Dim dt As DataTable
Dim dtToBind As DataTable = New DataTable()
dtToBind.Columns.Add("Contact Type", Type.GetType("System.String"))
dtToBind.Columns.Add("First Name", Type.GetType("System.String"))
dtToBind.Columns.Add("Last Name", Type.GetType("System.String"))
dtToBind.Columns.Add("Email Address", Type.GetType("System.String"))
dt = GetValues()
For Each dr As DataRow In dt.Rows
dtToBind.Rows.Add(dr(0).ToString(), dr(6).ToString(), dr(7).ToString(), dr(9).ToString())
Next
For Each dr As DataRow In dtToBind.Rows
Dim toButtonField = New ButtonField() With {
.ButtonType = ButtonType.Button,
.Text = "To: ",
.CommandName = "DoSomething"
}
Dim ccbuttonField = New ButtonField() With {
.ButtonType = ButtonType.Button,
.Text = "Cc: ",
.CommandName = "DoSomething"
}
gvContactList.Columns.Add(toButtonField)
gvContactList.Columns.Add(ccbuttonField)
Exit For
Next
gvContactList.DataSource = dtToBind
gvContactList.DataBind()
bttnTo.Attributes.Add("OnClientClick", "#emailAddress")
End Sub
LinkButton:
<asp:LinkButton runat="server" cssclass="fancybox" ID="bttnTo" OnClick="getEmailContacts"><span style='font-size: 20px; color: darkgreen'><i id="toEmail" class="fa fa-users sameRow margin10"></i></span></asp:LinkButton>
这也是JS文件中的最新内容
$(document).ready(function () {
$(".fancybox").fancybox({
parent: "form:first" // jQuery selector
});
});
标准链接
<a href="#emailAddresses" class="fancybox"><span style='font-size: 20px; color: darkgreen'><i id="toEmail" class="fa fa-users sameRow margin10"></i></span></a>
如何最好调用此功能?
答案 0 :(得分:1)
此处更新您的javascript
$(document).ready(function () {
fancybox = $(".fancybox").fancybox({
parent: "form:first" // jQuery selector
});
if (gridLoaded) {
fancybox.click();
}
});
首页加载时必须gridLoaded
为false,然后当您加载网格时,将gridLoaded
设置为true。