search this blog [2700+ asp.net c# examples]

Loading...

ASP.NET - Get the ConnectionStrings List programmatically

asp.net example: get the ConnectionStrings List programmatically
ConnectionStringsList.aspx
<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e) {
        GridView1.DataSource = System.Web.Configuration.WebConfigurationManager.ConnectionStrings;
        GridView1.DataBind();
        Label1.Text = "ConnectionStrings List Found.";
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Asp.Net Example: get the ConnectionStrings List programmatically</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Fuchsia">Get ConnectionStrings</h2>
        <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="DarkCyan"></asp:Label>
        <br />
        <asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" 
            GridLines="None">
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <RowStyle BackColor="#EFF3FB" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <EditRowStyle BackColor="#2461BF" />
            <AlternatingRowStyle BackColor="White" />
        </asp:GridView>
        <br />
        <asp:Button ID="Button1" runat="server" Text="Get ConnectionStrings List" OnClick="Button1_Click" Font-Bold="true" ForeColor="DarkGreen" />
    </div>
    </form>
</body>
</html>








Related asp.net example