如何使用多个按钮在模态扩展器内显示gridview [英] How display gridview inside modal extender with multiple button
问题描述
Gridview没有显示。我有3个按钮,我需要在模态扩展器内的gridview中显示结果。每个按钮都有不同的数据,以便在点击时显示在Gridview中。
我尝试了什么:
- 源代码 -
<%@ Page Language =VBAutoEventWireup =falseCodeFile =test.aspx.vbInherits =test% >
<%@ Register assembly =AjaxControlToolkitnamespace =AjaxControlToolkittagprefix =cc1%>
<!DOCTYPE html PUBLIC - // W3C // DTD XHTML 1.0 Transitional // ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd >
< title>
.modalPopup
{
background-color:#FFFFFF;
border-width :3px;
border-style:solid;
border-color:Blue;
padding-top:10px;
padding-left:10px;
宽度:400px;
身高:200px;
}
< asp:ScriptManager ID =ScriptManager1runat =server>
< asp:Button ID =btntestrunat =server Text =Show Modal Popup1
onclick =btntest_Click/>
< cc1:ModalPopupExtender ID =mp1 runat =serverPopupControlID =Panel1TargetControlID =btntest
CancelControlID =btnCloseBackgroundCssClass =modalBackground>
< asp:按钮ID =btntest2runat =serverText =Show Modal Popup2
onclick =btntest2_Click/>
< cc1:ModalPopupExtender ID =btntest2_ModalPopupExtenderrunat =server
PopupControlID =Panel1TargetControlID =btntest2
CancelControlID =btnCloseBackgroundCssClass =modalBackground>
< asp:按钮ID =btntest1runat = serverText =Show Modal Popup3
onclick =btntest1_Click/>
< cc1:ModalPopupExtender ID = btntest1_ModalPopupExtenderrunat =server
PopupControlID =Panel1TargetControlID =btntest1
CancelControlID =btnCloseBackgroundCssClass =modalBackground>
< asp:Panel ID =Panel1runat =serverCssClass =modalPopupalign = centerstyle =display:none>
< asp:GridView ID =GridView1runat =serverCellPadding =4ForeColor =#333333
GridLines =无>
< AlternatingRowStyle BackColor =白色/>
< EditRowStyle BackColor =#7C6F57/>
< FooterStyle BackColor =#1C5E55Font-Bold =TrueForeColor =White/>
< HeaderStyle BackColor =#1C5E55字体 - Bold =TrueForeColor =White/>
< PagerStyle BackColor =#666666ForeColor =WhiteHorizontal Align =Center/>
< RowStyle BackColor =#E3EAEB/>
< SelectedRowStyle BackColor =#C5BBAFFont-Bold =真ForeColor =#333333/>
< SortedAscendingCellStyle BackColor =#F8FAFA/>
< SortedAscendingHeaderStyle BackColor =#246B61/> ;
< SortedDescendingCellStyle BackColor =#D4DFE1/>
< SortedDescendingHeaderStyle BackColor =#15524A/>
< asp:按钮ID =btnCloserunat =server文字=关闭/>
--VC.code--
Partial类测试
继承System.Web.UI.Page
Dim cn,cn2 As New Data.SqlClient.SqlConnection(Data Source = Mydatasource; Initial Catalog = DevicesInventory; User ID = User; Password = Pass)
Dim da,da2 As New Data.SqlC lient.SqlDataAdapter
Dim sc,sc2 As New Data.SqlClient.SqlCommand
Dim ds,ds2 As New Data.DataSet
受保护的子Page_Load(ByVal发送者为对象,ByVal e As System.EventArgs)处理Me.Load
da2.SelectCommand = sc2
sc2.Connection = cn2
End Sub
受保护的子btntest2_Click(ByVal sender As Object,ByVal e As System.EventArgs)处理btntest2.Click
da2.SelectCommand = sc2
sc2.Connection = cn2
sc2.CommandText =选择不同的[项目]作为帐户,[楼层],[原型],[品牌],[序列号]来自tbldeviceinventory,其中stationnumber = '17 .101'
da2.Fill(ds2)
GridView1.DataSource = ds2
GridView1.DataBind()
ds2.Clear()
ds2.Tables.Clear ()
结束子
Protected Sub btntest1_Click(ByVal sender As Object,ByVal e As System.EventArgs)处理btntest1.Click
da2.SelectCommand = sc2
sc2.Connection = cn2
sc2.CommandText =选择不同的[项目]作为帐户,[楼层],[Devicetype],[品牌],[序列号]来自tbldeviceinventory,其中stationnumber = '17 .104'
da2.Fill(ds2)
GridView1.DataSource = ds2
GridView1.DataBind()
ds2.Clear()
ds2.Tables.Clear()
End Sub
受保护的子btntest_Click(ByVal sender As Object,ByVal e As System.Web.UI.ImageClickEventArgs)处理ImageButton1.Click
da2.SelectCommand = sc2
sc2.Connection = cn2
sc2.CommandText =选择不同的[项目]作为帐户,[楼层],[设计类型],[品牌],[序列号]来自tbldeviceinventory,其中stationnumber = '17 .105'
da2.Fill(ds2)
GridView1.DataSource = ds2
GridView1.DataBind()
ds2 .Clear()
ds2.Tables.Clear()
End Sub
结束类
Gridview not showing. I have 3 buttons and I need to display the result in the gridview inside the modal extender. each button has different data to display in Gridview when click.
What I have tried:
--Source Code--
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="test" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title>
.modalPopup
{
background-color: #FFFFFF;
border-width: 3px;
border-style: solid;
border-color: Blue;
padding-top: 10px;
padding-left: 10px;
width: 400px;
height: 200px;
}
<asp:ScriptManager ID="ScriptManager1" runat="server">
<asp:Button ID="btntest" runat="server" Text="Show Modal Popup1"
onclick="btntest_Click" />
<cc1:ModalPopupExtender ID="mp1" runat="server" PopupControlID="Panel1" TargetControlID="btntest"
CancelControlID="btnClose" BackgroundCssClass="modalBackground">
<asp:Button ID="btntest2" runat="server" Text="Show Modal Popup2"
onclick="btntest2_Click" />
<cc1:ModalPopupExtender ID="btntest2_ModalPopupExtender" runat="server"
PopupControlID="Panel1" TargetControlID="btntest2"
CancelControlID="btnClose" BackgroundCssClass="modalBackground">
<asp:Button ID="btntest1" runat="server" Text="Show Modal Popup3"
onclick="btntest1_Click" />
<cc1:ModalPopupExtender ID="btntest1_ModalPopupExtender" runat="server"
PopupControlID="Panel1" TargetControlID="btntest1"
CancelControlID="btnClose" BackgroundCssClass="modalBackground">
<asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" align="center" style = "display:none">
<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333"
GridLines="None">
<AlternatingRowStyle BackColor="White" />
<EditRowStyle BackColor="#7C6F57" />
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#E3EAEB" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F8FAFA" />
<SortedAscendingHeaderStyle BackColor="#246B61" />
<SortedDescendingCellStyle BackColor="#D4DFE1" />
<SortedDescendingHeaderStyle BackColor="#15524A" />
<asp:Button ID="btnClose" runat="server" Text="Close" />
--VB.code--
Partial Class test
Inherits System.Web.UI.Page
Dim cn, cn2 As New Data.SqlClient.SqlConnection("Data Source=Mydatasource;Initial Catalog=DevicesInventory;User ID=User;Password=Pass")
Dim da, da2 As New Data.SqlClient.SqlDataAdapter
Dim sc, sc2 As New Data.SqlClient.SqlCommand
Dim ds, ds2 As New Data.DataSet
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
da2.SelectCommand = sc2
sc2.Connection = cn2
End Sub
Protected Sub btntest2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btntest2.Click
da2.SelectCommand = sc2
sc2.Connection = cn2
sc2.CommandText = "select distinct [Project] as Account, [Floor], [Devicetype],[Brand],[Serialnumber] from tbldeviceinventory where stationnumber='17.101'"
da2.Fill(ds2)
GridView1.DataSource = ds2
GridView1.DataBind()
ds2.Clear()
ds2.Tables.Clear()
End Sub
Protected Sub btntest1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btntest1.Click
da2.SelectCommand = sc2
sc2.Connection = cn2
sc2.CommandText = "select distinct [Project] as Account, [Floor], [Devicetype],[Brand],[Serialnumber] from tbldeviceinventory where stationnumber='17.104'"
da2.Fill(ds2)
GridView1.DataSource = ds2
GridView1.DataBind()
ds2.Clear()
ds2.Tables.Clear()
End Sub
Protected Sub btntest_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
da2.SelectCommand = sc2
sc2.Connection = cn2
sc2.CommandText = "select distinct [Project] as Account, [Floor], [Devicetype],[Brand],[Serialnumber] from tbldeviceinventory where stationnumber='17.105'"
da2.Fill(ds2)
GridView1.DataSource = ds2
GridView1.DataBind()
ds2.Clear()
ds2.Tables.Clear()
End Sub
End Class
推荐答案
您的面板不可见。我没看到你在哪里展示它。这东西很古老,我不知道为什么人们仍然使用它。图书馆应该让它可见吗?
我会创建一个只包含文本的弹出窗口。使其工作,然后开始扩展它以添加控件
Your panel is not visible. I don't see where you show it. This stuff is ancient, I don't know why people still use it. Is the library supposed to make it visible?
I would create a popup with just text in it. Make that work, then start expanding it to add your controls
这篇关于如何使用多个按钮在模态扩展器内显示gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!