TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Kavi suja
NA
298
171.2k
OOPS concept - Gridview Data Bind
Jul 23 2013 7:23 AM
Hi,
I have register page and view page.In Register page I insert data in to database.In view page,all the data entered in Register page will be shown in Grid.I use Stored procedure for this.Now I've to done this task using anyone of oops concept.But i don't know so much about oops concept.How I use oops concept here?Can anyone help me to do this?
I include my code here:
protected void Page_Load(object sender, EventArgs e)
{
con = new MySqlConnection("server=localhost;User Id=root;database=userdata;password=MySqlAdmin");
con.Open();
if (!IsPostBack)
{
BindGridView();
}
}
private void BindGridView()
{
using (MySqlConnection con = new MySqlConnection("server=localhost;User Id=root;database=userdata;password=MySqlAdmin"))
{
DataSet ds = new DataSet();
MySqlCommand cmd = new MySqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "viewdata";
cmd.Connection = con;
try
{
con.Open();
gvcontact.EmptyDataText = "No Records Found";
gvcontact.DataSource = cmd.ExecuteReader();
gvcontact.DataBind();
}
catch (Exception ex)
{
throw ex;
}
finally
{
con.Close();
con.Dispose();
}
Reply
Answers (
5
)
how to bind one dropdown item when we get it from db ?
Name of dbconnection correct. But still wrong connection...