How to Binding


How to Binding GridView in asp.net
In this article, I will explain how to binding GridView in asp.net.
Let start to

Step-1:- I have created table in database & give name Product.
After that I inserted 7-8 value in Product table as follow.

Step-2:-After that design aspx page & give name BindGridView.aspx.
We required 1)Grid View as follow.

Step-3:- After that design aspx page, I have one grid view I need to write code to Bind GridView To table Product, I created a method is called GridViewBind(); & call this method in Page_Load.

You have to add following namespace in code behind(.cs)

using System.Data.SqlClient;  //add this namespace

BindGridView.aspx .cs

using System;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Xml.Linq;

using System.Data.SqlClient; //add this namespace

public partial class GridviewBindingTODB : System.Web.UI.Page
{
    string constring = ConfigurationManager.ConnectionStrings["MyWebConfigString"].ConnectionString;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            GridViewBind();
        }

    }
    private void GridViewBind()
    {
        SqlConnection conn = new SqlConnection(constring);

        conn.Open();
        SqlCommand cmd = new SqlCommand("select * from producttable", conn);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        da.Fill(ds);
        GridView1.DataSource = ds;
        GridView1.DataBind();
    }
}
Step-4:- Build-àSaveàRun.




http://www.extremetechblog.com/add-code-snippet-to-posts-in-blogger/
<div class='code'>
Your code should be pasted here in this div tag.
</div>
Your code should be pasted here in this div tag. Create PROCEDURE dbo.AddClientRegistration ( @fname nvarchar (50), @lname nvarchar(50), @mobile varchar(50), @address ntext ) AS /* SET NOCOUNT ON */ Insert INTO ClientRegistration ( fname,lname,mobile,address ) VALUES( @fname,@lname,@mobile,@address) RETURN

No comments:

Tabs


Tab 1 content goes here

Tab 2 content goes here

Tab 3 content goes here
Multi-Tabbed Widget | DotNetIs