ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Bind (Populate) GridView using C# in ASP.Net<p>Dear Team,</p> <p>Thanks for help.</p> <p>.aspx</p> <pre class="brush: html">&lt;%@ Page Language=&#34;C#&#34; AutoEventWireup=&#34;true&#34; Codefile=&#34;teldir.aspx.cs&#34; Inherits=&#34;Url.teldir&#34; %&gt; &lt;!DOCTYPE html&gt; &lt;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&gt; &lt;head runat=&#34;server&#34;&gt; &lt;title&gt;&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form id=&#34;form1&#34; runat=&#34;server&#34;&gt; &lt;h1&gt;Department Directory&lt;/h1&gt; &lt;div&gt; &lt;asp:GridView ID=&#34;GridView1&#34; runat=&#34;server&#34;&gt;&lt;/asp:GridView&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt;</pre> <p>&nbsp;.aspx.cs</p> <pre class="brush: csharp">using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient; using System.Configuration; namespace Url { public partial class teldir : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { SqlConnection con = new SqlConnection(); con.ConnectionString = ConfigurationManager.ConnectionStrings[&#34;myconnection&#34;].ToString(); con.Open(); SqlCommand cmd = new SqlCommand(); string s = &#34;select * from emp_mast1 where dept_code=08&#34;; SqlDataAdapter da = new SqlDataAdapter(s, con); DataSet ds = new DataSet(); da.Fill(ds); GridView1.DataSource = ds; //to show dATA GridView1.DataBind(); con.Close(); } } }</pre> <p>Thanks to asp team.</p> <p>Regards,</p> <p>Indradeo</p>https://www.aspforums.net:443/Threads/222089/Bind-Populate-GridView-using-C-in-ASPNet/https://www.aspforums.net:443/Threads/222089/Bind-Populate-GridView-using-C-in-ASPNet/Mon, 22 Jul 2019 01:41:30 GMT