<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Caption="Customer List" AllowPaging="true" PageSize="10" EmptyDataText="You have deleted all records in customer list">
<RowStyle Height="40px" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Panel ID="Panel1" runat="server" Width="400px">
<asp:Label ID="Label4" runat="server" Text='<%# Eval("Id") %>'></asp:Label>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("StationName") %>'></asp:Label>
</asp:Panel>
<cc1:HoverMenuExtender ID="HoverMenuExtender1" runat="server" PopupControlID="PopupMenu" TargetControlID="Panel1" PopupPosition="Left"> </cc1:HoverMenuExtender>
<asp:Panel ID="PopupMenu" runat="server" CssClass="popupMenu">
<asp:Image ID="Image1" runat="server" CssClass="popupHover" ImageUrl='<%# Eval("Warning_Upstream","~/Images/{0}") %>' Height="50px" Width="50px"/>
</asp:Panel>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = this.GetData("select * from Stations");
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
private DataTable GetData(string query)
{
string conString = ConfigurationManager.ConnectionStrings["ConString"].ConnectionString;
MySqlCommand cmd = new MySqlCommand(query);
using (MySqlConnection con = new MySqlConnection(conString))
{
using (MySqlDataAdapter sda = new MySqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (DataTable dt = new DataTable())
{
sda.Fill(dt);
return dt;
}
}
}
}