Auto Refresh Data Grid View

using vs2008, sql 2005, asp.net VB

Page 1 of 1

5 Replies - 11647 Views - Last Post: 26 October 2009 - 12:42 PM Rate Topic: -----

#1 syahman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 24-October 09

Auto Refresh Data Grid View

Posted 26 October 2009 - 11:34 AM

When i insert data in database, the page at Gridview not automatically show. So i must refresh the page to view the new item show the data Gridview. Is there any wrong with my insert command? Are there any best solution to solve my prob. For the information the page 1 is for insert the data and page 2 is view the GridView. For the example of sample code will be very helpful. Tq
Is This A Good Question/Topic? 0
  • +

Replies To: Auto Refresh Data Grid View

#2 ramesh866  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 91
  • Joined: 03-October 09

Re: Auto Refresh Data Grid View

Posted 26 October 2009 - 11:46 AM

so you are keeping inserting of data in one form and grid view in another. am i getting you right?
Was This Post Helpful? 0
  • +
  • -

#3 syahman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 24-October 09

Re: Auto Refresh Data Grid View

Posted 26 October 2009 - 12:00 PM

View Postramesh866, on 26 Oct, 2009 - 10:46 AM, said:

so you are keeping inserting of data in one form and grid view in another. am i getting you right?


Yes
Was This Post Helpful? 0
  • +
  • -

#4 ramesh866  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 91
  • Joined: 03-October 09

Re: Auto Refresh Data Grid View

Posted 26 October 2009 - 12:08 PM

when you navigate from insert page to grid view page, the page gets post back. so you can refresh the data content in the ispostback event or on load event and use a data set and call the fill method .
Was This Post Helpful? 0
  • +
  • -

#5 syahman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 24-October 09

Re: Auto Refresh Data Grid View

Posted 26 October 2009 - 12:12 PM

View Postramesh866, on 26 Oct, 2009 - 11:08 AM, said:

when you navigate from insert page to grid view page, the page gets post back. so you can refresh the data content in the ispostback event or on load event and use a data set and call the fill method .


Can u give some example code ... it really helpful for me... i'm new in ASP.net
Was This Post Helpful? 0
  • +
  • -

#6 ramesh866  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 91
  • Joined: 03-October 09

Re: Auto Refresh Data Grid View

Posted 26 October 2009 - 12:42 PM

this can be done this way too.
in button click type this code for string the data in database
  protected void Button2_Click(object sender, EventArgs e)
	{
		string app = ConfigurationManager.ConnectionStrings["ASPConnectionString"].ConnectionString;
		System.Data.SqlClient.SqlConnection cn = new System.Data.SqlClient.SqlConnection(app);
		cn.Open();
		if (cn.State.ToString() == "Open")
		{
			Response.Write("open");

			System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("insert into ASP (name)values('" + TextBox1.Text + "')", cn);
			cmd.ExecuteNonQuery();
		}
		else
		{
			Response.Write("failed");
		}
	}


change the insert values in command objects as applicable.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1