Asp.net 在gridview中显示gridview
我有一个关于招聘系统的项目。在这个项目中,我有gridview,它包含空缺职位、公司名称、部门名称等详细信息。现在我想要的是,空缺职位上应该有超链接,当用户单击空缺职位时,它应该在另一个网格中显示该空缺的标准,而不刷新该页面。这意味着我必须在另一个网格中维护一个网格,但我不知道如何实现这一点。Asp.net 在gridview中显示gridview,asp.net,Asp.net,我有一个关于招聘系统的项目。在这个项目中,我有gridview,它包含空缺职位、公司名称、部门名称等详细信息。现在我想要的是,空缺职位上应该有超链接,当用户单击空缺职位时,它应该在另一个网格中显示该空缺的标准,而不刷新该页面。这意味着我必须在另一个网格中维护一个网格,但我不知道如何实现这一点。 有谁能给我指点迷津吗?亲爱的朋友,我在数据列表中使用了gridview,所以您可以用同样的方法使用 gridview中的grid视图。下面是代码示例 .aspx代码 <asp:DataList
有谁能给我指点迷津吗?亲爱的朋友,我在数据列表中使用了gridview,所以您可以用同样的方法使用 gridview中的grid视图。下面是代码示例 .aspx代码
<asp:DataList ID="dl_College" runat="server" OnItemCommand="dl_College_ItemCommand"
OnItemDataBound="dl_College_ItemDataBound">
<ItemTemplate>
<fieldset>
<asp:GridView ID="grdCorse" runat="server" AutoGenerateColumns="false" CssClass="text12_d"
Width="100%">
<HeaderStyle BackColor="#244e7e" ForeColor="#f7f7f7" />
<RowStyle CssClass="gridview-row" />
<Columns>
<asp:TemplateField HeaderText="Stream Name">
<HeaderStyle CssClass="grdsize" />
<ItemStyle Width="42%" />
<ItemTemplate>
<span class="text12_d">
<%#Eval("StreamName")%>
</span>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Seats">
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" Width="10%" />
<ItemTemplate>
<%#Eval("StreamSeats")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Duration">
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" Width="10%" />
<ItemTemplate>
<%#Eval("StreamDuration")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Fee">
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" Width="15%" />
<ItemTemplate>
<asp:Label ID="lblStreamFee" runat="server" Text='<%#Eval("StreamFees")%>' Visible="false"></asp:Label>
<asp:ImageButton ID="imgLock" runat="server" PostBackUrl='<%# String.Format("{0}{1}","Login.aspx?ClgId=" , Eval("CollegeId")) %>'
CausesValidation="false" ImageUrl="~/images/Lock.png" Width="30" Height="20" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Mode">
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" Width="10%" />
<ItemTemplate>
<%#Eval("StreamMode")%>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</fieldset>
<br />
<asp:Panel ID="pnlCollegeRank" runat="server">
<fieldset>
<legend class="Legend_Header"><strong>College Rank</strong></legend>
<asp:Panel ID="pnlImage" runat="server" Visible="false">
<table width="100%">
<tr>
<td style="width: 100%;" class="Main_StripCollegeRank">
To check college rank, please login
</td>
<td style="float: right; background-color: #3b5998;">
<asp:ImageButton ID="imgLock" PostBackUrl='<%# String.Format("{0}{1}","Login.aspx?Collegeid=" , Eval("CollegeId")) %>'
CausesValidation="false" ImageUrl="~/images/Lock.png" runat="server" />
</td>
</tr>
</table>
</asp:Panel>
<asp:Panel ID="pnlRank" runat="server" Visible="false">
<span style="float: left; padding-left: 6px; width: auto">
<asp:GridView ID="grdCollegeRank" runat="server" AutoGenerateColumns="false" CssClass="text12_d"
Width="">
<HeaderStyle ForeColor="White" />
<RowStyle CssClass="gridview-row" />
<AlternatingRowStyle BackColor="#fffbfd" />
<Columns>
<asp:TemplateField HeaderText="">
<HeaderTemplate>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr style="background-color: #244e7e">
<td style="width: 100%; background-color: #244e7e; font-size: 13px; font-weight: bold;
color: white; padding-left: 3px" colspan="2" align="left">
College Rank in
<asp:Label ID="lblYear" runat="server" Text="2011" ForeColor="white" Font-Size="13px"
Font-Bold="true"></asp:Label>
</td>
</tr>
<tr>
<td style="width: auto; color: #244e7e; text-align: left;" class="grid_HeaderRank">
Source
</td>
<td style="width: auto; color: #244e7e; text-align: right;" class="grid_HeaderRank">
Rank
</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="width: auto;" align="left" class="text12_d">
<asp:Label ID="lblSource" runat="server" Text='<%#Eval("SourceName")%>'></asp:Label>
</td>
<td style="width: auto; text-align: right; padding-right: 16px" class="text12_d">
<asp:Label ID="lblRank" runat="server" Text='<%#Eval("OverallRank")%>'></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</span><span style="float: left; padding-left: 6px; width: auto">
<asp:GridView ID="grdCollegeRank1" runat="server" AutoGenerateColumns="false" CssClass="text12_d"
Width="">
<HeaderStyle ForeColor="White" />
<RowStyle CssClass="gridview-row" />
<AlternatingRowStyle BackColor="#fffbfd" />
<Columns>
<asp:TemplateField HeaderText="">
<HeaderTemplate>
<table width="100%">
<tr style="background-color: #244e7e">
<td style="width: 100%; background-color: #244e7e; font-size: 13px; font-weight: bold;
color: white; padding-left: 3px" colspan="2" align="left">
College Rank in
<asp:Label ID="lblYear" runat="server" Text="2010" ForeColor="white" Font-Size="13px"
Font-Bold="true"></asp:Label>
</td>
</tr>
<tr>
<td style="width: auto; color: #244e7e; text-align: left;" class="grid_HeaderRank">
Source
</td>
<td style="width: auto; color: #244e7e; text-align: right;" class="grid_HeaderRank">
Rank
</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table width="100%">
<tr>
<td style="width: auto;" align="left" class="text12_d">
<asp:Label ID="lblSource" runat="server" Text='<%#Eval("SourceName")%>'></asp:Label>
</td>
<td style="width: auto; text-align: right; padding-right: 16px" class="text12_d">
<asp:Label ID="lblRank" runat="server" Text='<%#Eval("OverallRank")%>'></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</span><span style="float: left; padding-left: 6px; width: auto">
<asp:GridView ID="grdCollegeRank2" runat="server" AutoGenerateColumns="false" CssClass="text12_d"
Width="">
<HeaderStyle ForeColor="White" />
<RowStyle CssClass="gridview-row" />
<AlternatingRowStyle BackColor="#fffbfd" />
<Columns>
<asp:TemplateField HeaderText="">
<HeaderTemplate>
<table width="100%">
<tr style="background-color: #244e7e">
<td style="width: 100%; background-color: #244e7e; font-size: 13px; font-weight: bold;
color: white; padding-left: 3px" colspan="2" align="left">
College Rank in
<asp:Label ID="lblYear" runat="server" Text="2009" ForeColor="white" Font-Size="13px"
Font-Bold="true"></asp:Label>
</td>
</tr>
<tr>
<td style="width: auto; color: #244e7e; text-align: left;" class="grid_HeaderRank">
Source
</td>
<td style="width: auto; color: #244e7e; text-align: right;" class="grid_HeaderRank">
Rank
</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table width="100%">
<tr>
<td style="width: auto;" align="left" class="text12_d">
<asp:Label ID="lblSource" runat="server" Text='<%#Eval("SourceName")%>'></asp:Label>
</td>
<td style="width: auto; text-align: right; padding-right: 16px" class="text12_d">
<asp:Label ID="lblRank" runat="server" Text='<%#Eval("OverallRank")%>'></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</span><span style="float: right; padding-right: 0px; width: 50%">
<asp:LinkButton ID="lnkCollegeRank" CommandName="ViewMore" CausesValidation="false"
runat="server" CssClass="ReadMore">View More...</asp:LinkButton>
</span>
</asp:Panel>
</fieldset>
<br />
</asp:Panel>
<fieldset>
<legend class="Legend_Header"><strong>Infrastructure</strong></legend>
<br />
<asp:GridView ID="grdHostelInformation" runat="server" AutoGenerateColumns="false"
CssClass="text12_d" Width="100%">
<HeaderStyle BackColor="#244e7e" ForeColor="#f7f7f7" />
<RowStyle CssClass="gridview-row" />
<Columns>
<asp:TemplateField HeaderText="Hostel">
<ItemStyle Width="10%" />
<HeaderStyle CssClass="grdsize" />
<ItemTemplate>
<a href="#" target="_blank" class="text12_d">
<%#Eval("CollegeHostelInfo")%>
</a>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Location">
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<%#Eval("HostelLocation")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Internet">
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<%#Eval("HostelInteranet")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Laundry">
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<%#Eval("HostelLaundry")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Power Backup">
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<%#Eval("HostelElectricityBackup")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="AC">
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<%#Eval("HostelAC")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Charges">
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<%#Eval("HostelCharges")%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Occupancy">
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<%#Eval("HostelOccupacy")%>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</fieldset>
<br />
<fieldset>
<legend class="Legend_Header"><strong>Contact Details</strong></legend>
<ul style="vertical-align:top; background-color:#f4faff;">
<li class="textLiExam">
<strong style="font-weight:bold; font-size:14px; color:Black;">Address :</strong>
<%# Eval("CollegeStreet")%>
<%# Eval("CollegeDistrict")%>
<%# Eval("StateName")%>
<%# Eval("CollegePinCode")%>
</li>
<li class="textLiExam">
<strong style="font-weight:bold; font-size:14px; color:Black;">Email Id : </strong>
<%# Eval("CollegePersonEmail")%>
</li>
<li class="textLiExam">
<strong style="font-weight:bold; font-size:14px; color:Black;">Website : </strong>
<a href='<%# String.Format("{0}{1}","http://" , Eval("CollegeWebsite")) %>'
target="_blank" class="textLiExam">
<%# Eval("CollegeWebsite")%>
</a>
</li>
<li class="textLiExam">
<strong style="font-weight:bold; font-size:14px; color:Black;">Phone : </strong>
<%# Eval("CollegePhone1")%>
,
<%# Eval("CollegePhone2")%>
</li>
<li class="textLiExam">
<strong style="font-weight:bold; font-size:14px; color:Black;">Fax : </strong>
<%# Eval("CollegeFax")%>
</li>
</ul>
</fieldset>
</ItemTemplate>
</asp:DataList>
因此,您可以在数据列表中找到gridview,我使用了Colorbox插件做了类似的事情 当您知道链接将导致页面加载时可以在页面中预编译的网格时,这种方法就起作用了 如果允许弹出窗口显示网格,则这可能是您的选择 a) 在页面上有一个占位符来存储生成的html代码 您将需要每个链接的唯一标识符 b) 从代码隐藏,我正在构建网格 --剪断--
使用{.Text=”“,.HorizontalAlign=HorizontalAlign.Center}将mystat暗显为新的TableCell
myrow.Cells.Add(mystat)
制备胺基转移酶组(myoraclefilter.ToString,(文本显示与h&i&j.ToString)
---剪断--
锚点指向同一个页面,更重要的是我正在构建的类,因为这是colorbox插件用于查找需要显示的网格的类。PrepareMinidaStatSet是一个函数,我在其中从数据库后端检索详细信息(您可能不需要它)。独特的组合texttoappear&h&i&j成为以后在我的函数中使用的“参考”字符串。(h、i和j是我在网格中的位置,因此每个字段都是唯一的)
c) I)然后我正在构建datagrid,以通过一个函数显示,使用从数据库中获取的数据作为数据集ds
Private Sub prepareminigrid(ByVal reference As String, ByRef myds As DataSet)
Dim Itemheader As Control = LoadControl("warrantydetailgrid.ascx")
Dim thegrid As GridView = CType(Itemheader.FindControl("mygrid"), GridView)
thegrid.DataSource = myds
thegrid.DataBind()
myhiddenpopups.Controls.Add(New LiteralControl("<div id='" & reference & "' style='padding:10px; background:#fff;'> "))
myhiddenpopups.Controls.Add(Itemheader)
myhiddenpopups.Controls.Add(New LiteralControl("</div>"))
If Not strScript.ToString.Contains("$('." & reference & "').colorbox({width:'50%', inline:true, href:'#" & reference & "'});") Then
strScript.AppendLine("$('." & reference & "').colorbox({width:'50%', inline:true, href:'#" & reference & "'});")
End If
End Sub
Private Sub prepareminigrid(ByVal引用作为字符串,ByRef myds作为数据集)
Dim Itemheader As Control=LoadControl(“warranseydetailgrid.ascx”)
将网格调整为GridView=CType(Itemheader.FindControl(“mygrid”),GridView)
thegrid.DataSource=myds
thegrid.DataBind()
myhiddenpups.Controls.Add(新的LiteralControl(“”)
MyHiddenPups.Controls.Add(Itemheader)
myhiddenpups.Controls.Add(新的LiteralControl(“”)
如果不是strScript.ToString.Contains($('.'')&reference&'').colorbox({width:'50%,inline:true,href:'#“&reference&'});),则
strScript.AppendLine($('.'&reference&').colorbox({width:'50%,inline:true,href:'#'&reference&'});)
如果结束
端接头
二) MyHiddenPups是我在aspx页面上添加html代码的占位符(这样colorbox可以在我按下定位键时检索它三) 最后,strscript是一个startupscript,它将向StartupJavaScript添加具有唯一标记(=引用)的不同colorbox函数 那它看起来像什么? 这是带有锚定标记的构建网格 这是当用户单击链接时显示的网格 在main.aspx页面上,您需要占位符,该占位符不会显示数据 当“prepareminigrid”为需要创建的每个锚运行时,来自编译页面的结果 您可以看到每个锚的唯一DIV id(这是colorbox函数将在inlin html代码中查找的内容)和下表 缺点是预加载的数据需要相对较小。如果您有一个包含数百行的表,页面的加载时间将增加,最终用户将收到“脚本需要很长时间才能完成”警告消息 希望能有帮助 K
Dim mystat As New TableCell With {.Text = "<a href='#' class='" & texttoappear & h & i & j & "'>" & mycount & "</a>", .HorizontalAlign = HorizontalAlign.Center}
myrow.Cells.Add(mystat)
prepareminidataset(myoraclefilter.ToString, (texttoappear & h & i & j).ToString)
Private Sub prepareminigrid(ByVal reference As String, ByRef myds As DataSet)
Dim Itemheader As Control = LoadControl("warrantydetailgrid.ascx")
Dim thegrid As GridView = CType(Itemheader.FindControl("mygrid"), GridView)
thegrid.DataSource = myds
thegrid.DataBind()
myhiddenpopups.Controls.Add(New LiteralControl("<div id='" & reference & "' style='padding:10px; background:#fff;'> "))
myhiddenpopups.Controls.Add(Itemheader)
myhiddenpopups.Controls.Add(New LiteralControl("</div>"))
If Not strScript.ToString.Contains("$('." & reference & "').colorbox({width:'50%', inline:true, href:'#" & reference & "'});") Then
strScript.AppendLine("$('." & reference & "').colorbox({width:'50%', inline:true, href:'#" & reference & "'});")
End If
End Sub