// This
method is used to bind gridview from database
protected void BindGridview()
{
using (SqlConnection con = new
SqlConnection("Data
Source=SureshDasari;Integrated Security=true;Initial Catalog=MySampleDB"))
{
con.Open();
SqlCommand cmd = new SqlCommand("Select UserName,LastName,Location FROM
UserInformation", con);
SqlDataReader dr =
cmd.ExecuteReader();
gvUserInfo.DataSource =
dr;
gvUserInfo.DataBind();
con.Close();
}
}
|
' This method is
used to bind gridview from database
Protected Sub
BindGridview()
Using con As New SqlConnection("Data
Source=SureshDasari;Integrated Security=true;Initial Catalog=MySampleDB")
con.Open()
Dim cmd As New SqlCommand("Select UserName,LastName,Location FROM
UserInformation", con)
Dim dr As
SqlDataReader = cmd.ExecuteReader()
gvUserInfo.DataSource = dr
gvUserInfo.DataBind()
con.Close()
End Using
End Sub
|
|
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
Subscribe by RSS
Subscribe by Email
|
|||
|
|
Subscribe by RSS
Subscribe by Email
5 comments :
your post is very easy and clear to understand
Hi Suresh, Good Job!! keep it up. this blog is very useful for Developers.
hi suresh... i am your big fan...pls post the concept of cookies
hi suresh... i am your big fan...pls post the concept of cookies
Dear Suresh, I have a student database. I want simple VB.net code where on page load event, some fields (like stuname, age std, etc) from my db should get bind in label /txtbox. I have googled lot on internet but not find satisfactory result.
Please help
MayurS - sawantmayur2005@gmail.com