I am using the Gridview custom paging code found here:http://www.asp.net/learn/dataaccess/tutorial25vb.aspx?tabid=63
On my page I also have a button which hides the gridview and shows a formview that is used for updating and inserting records that are displayed in the gridview. My problem is when I add a record via the formview and then the Gridview is shown again if the
record should be on the same page of data that is shown it doesn't show up (it correctly is added to the database). If I switch to a different select datasource on my object datasource it then shows up in the list.
I hope this makes sense, any help greatly appreciated.
Where do you call the DataBind method? Do you do it in the method where you display the Grid again after you insert a value with the FormView?
If you use a data-source control and call the GridView's DataBind method, the GridView will make a call to the data-source Select method and rebind the new values. If you don't use the data-source control, make sure you also call your method that gets the
value from the data source and set it to the GridView's DataSource property, after that call the DataBind method.
At least the DataBind method refresh my grid, I usually hook up to the data-source updated or inserted event and call the DataBind method directly after the Inert and Update has executed.
[quote user="Fredrik N"] At least the DataBind method refresh my grid, I usually hook up to the data-source updated or inserted event and call the DataBind method directly after the Inert and Update has executed.
I am having the same type of problem but I have a DropDownList that is being bound to an AccessDataSource.
Below the form that this is a part of, I have another form (these are two seperate forms on the same web form). This second form allows you to add a new record to the table that is populating the DropDownList from the other form. After inserting the new
record, the DropDownList is not getting the new value even though I am calling DataBind(), however if I step through it while debugging, it works. Any ideas?
Got it fixed. Although I was using a different connection, I had to close the INSERT statements' connection before it would DataBind() the other datasource object.
Thank Ya'll so much I have been looking for this answer all day now... In fact I just posted the same question on here (yes like a DumbA$$ before searching the forum first)
Cool anyhow thank each of you for your input on this You guys ROCK
simmy007
Member
175 Points
59 Posts
Refresh Gridview after insert
Oct 15, 2006 01:24 PM|LINK
I am using the Gridview custom paging code found here:http://www.asp.net/learn/dataaccess/tutorial25vb.aspx?tabid=63
On my page I also have a button which hides the gridview and shows a formview that is used for updating and inserting records that are displayed in the gridview. My problem is when I add a record via the formview and then the Gridview is shown again if the record should be on the same page of data that is shown it doesn't show up (it correctly is added to the database). If I switch to a different select datasource on my object datasource it then shows up in the list.
I hope this makes sense, any help greatly appreciated.
gridview "custom paging" refresh insert
Fredrik N
All-Star
29674 Points
5334 Posts
MVP
Re: Refresh Gridview after insert
Oct 15, 2006 01:45 PM|LINK
MVP, ASPInsider, WCF RIA Services Insider
My Blog
simmy007
Member
175 Points
59 Posts
Re: Refresh Gridview after insert
Oct 15, 2006 02:25 PM|LINK
rexlin
Star
9403 Points
1751 Posts
Re: Refresh Gridview after insert
Oct 16, 2006 03:15 AM|LINK
Hi,simmy007 :
Make sure you do not bind your GV on each postback in Page_Load() event.
protected void Page_Load()
{
if(!IsPostBack)
//Bind your GV}
Best Regards,
__________________________________________________
Sincerely,
Rex Lin
Microsoft Online Community Support
This posting is provided "AS IS" with on warranties, and confers no rights.
Fredrik N
All-Star
29674 Points
5334 Posts
MVP
Re: Refresh Gridview after insert
Oct 16, 2006 05:28 AM|LINK
Where do you call the DataBind method? Do you do it in the method where you display the Grid again after you insert a value with the FormView?
If you use a data-source control and call the GridView's DataBind method, the GridView will make a call to the data-source Select method and rebind the new values. If you don't use the data-source control, make sure you also call your method that gets the value from the data source and set it to the GridView's DataSource property, after that call the DataBind method.
At least the DataBind method refresh my grid, I usually hook up to the data-source updated or inserted event and call the DataBind method directly after the Inert and Update has executed.
MVP, ASPInsider, WCF RIA Services Insider
My Blog
simmy007
Member
175 Points
59 Posts
Re: Refresh Gridview after insert
Oct 16, 2006 12:39 PM|LINK
[quote user="Fredrik N"] At least the DataBind method refresh my grid, I usually hook up to the data-source updated or inserted event and call the DataBind method directly after the Inert and Update has executed.
That did it! Thanks!
tsimes
Member
10 Points
2 Posts
Re: Refresh Gridview after insert
Oct 17, 2006 09:26 PM|LINK
I am having the same type of problem but I have a DropDownList that is being bound to an AccessDataSource.
Below the form that this is a part of, I have another form (these are two seperate forms on the same web form). This second form allows you to add a new record to the table that is populating the DropDownList from the other form. After inserting the new record, the DropDownList is not getting the new value even though I am calling DataBind(), however if I step through it while debugging, it works. Any ideas?
tsimes
Member
10 Points
2 Posts
Re: Refresh Gridview after insert
Oct 18, 2006 06:25 PM|LINK
scripter26
Member
441 Points
191 Posts
Re: Refresh Gridview after insert
Oct 23, 2006 10:09 PM|LINK
Thank Ya'll so much I have been looking for this answer all day now... In fact I just posted the same question on here (yes like a DumbA$$ before searching the forum first)
Cool anyhow thank each of you for your input on this You guys ROCK
Coasties.com
corrock
Member
2 Points
2 Posts
Re: Refresh Gridview after insert
Oct 24, 2007 10:03 PM|LINK
Nice, thanks that worked for me as well