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

Loading...

Show ConnectionStrings list programmatically in a ListBox in asp.net

How to get ConnectionStrings list programmatically in asp.net
GetConnectionStrings.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) {
        ListBox1.DataSource = System.Web.Configuration.WebConfigurationManager.ConnectionStrings;
        ListBox1.DataBind();
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>How to get ConnectionStrings list programmatically in asp.net</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style=" color:Fuchsia">Get ConnectionStrings List Example</h2>
        <br />
        <b>ConnectionStrings</b>
        <br />
        <asp:ListBox ID="ListBox1" runat="server"></asp:ListBox>
        <br /><br />
        <asp:Button ID="Button1" runat="server" Text="Get ConnectionStrings List" OnClick="Button1_Click" />
    </div>
    </form>
</body>
</html>






Related asp.net example