1
Answer

how to get data from npgsql to dropdownlist c#

<asp:dropdownlist ID="EndtypeDL" CssClass="form-control" AutoPostBack="true" runat="server" OnSelectedIndexChanged="EndtypeDL_SelectedIndexChanged">
</asp:dropdownlist>
 
var connString = WebConfigurationManager.AppSettings["ConnectionDB"];
var conDrop = new NpgsqlConnection(connString);
 
how to next? 
 thank you
Answers (1)
0
Vinod L

Vinod L

NA 249 6.3k 7y
You can use Dapper ORM, it is very efficient to way to access data from Postgre Sql.
 
Check it, 
 http://dapper-tutorial.net/dapper
 
//Connection String for Postgre  
  1. var connectionString = "Username=****;Password=****;Host=*Server Address*;Port=*Port*;Database=*Database Name*;Pooling=true;";  
  2. var conn = new NpgsqlConnection(connectionString);   
 
//Binding Process
In Dapper Orm you get many methods, you can use Query Method to execute your Query and return the list and bind that list to your Dropdown.
 
  1. return conn.Query(query).ToList();