Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Updated 10-May-18 12:36pm

1 solution

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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900