473,413 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

Refreshing SqlDataSource on page roundtrip?

Hi,

I have SqlDataSource control that makes a "select count" to show how many
rows there are in a Table and it is working fine on first page load.
The problem is that when I am inserting a new row to the database table at
the same ASPX page the rows count from the SqlDataSource remain the same.

To refresh the SqlDataSource I have used his
Select(DataSourceSelectArguments.Empty) but no luck.

How can I refresh the SqlDataSource after I am inserting a new row to the
database table using the TableAdapter?

Thanks in advanced for any help,
Asaf

Oct 29 '06 #1
3 9228
Call the TableAdapter's Fill method.

--
HTH,

Kevin Spencer
Microsoft MVP
Short Order Coder
http://unclechutney.blogspot.com

The devil is in the yada yada yada
"Asaf" <AG**@newsgroups.nospamwrote in message
news:E9**********************************@microsof t.com...
Hi,

I have SqlDataSource control that makes a "select count" to show how many
rows there are in a Table and it is working fine on first page load.
The problem is that when I am inserting a new row to the database table at
the same ASPX page the rows count from the SqlDataSource remain the same.

To refresh the SqlDataSource I have used his
Select(DataSourceSelectArguments.Empty) but no luck.

How can I refresh the SqlDataSource after I am inserting a new row to the
database table using the TableAdapter?

Thanks in advanced for any help,
Asaf

Oct 29 '06 #2
Hello Asaf,

Are you use a SqlDatasource or ObjectDataSource control to retrieve the
Count of records in a table? Based on my understanding, only
ObjectDataSource can be configured to use TableAdapter component and
SqlDataSource will hide the code logic of underlying data accessing.

Also, after you have get the count data from
DataSourceControl(sqlDatasrouce or objectdatasource), how do you display
the value on control, use databinding (through DataSourceId) or manually
call DataSource.Select method and assign the return value to the target
control?

If you are using databinding approach, you just need to recall the
"DataBind" method of the target control(such as GridView ) after you've
peformed inserting or updating in the backend database. e.g.

suppose I use another DetailsView to insert data into backend data, I can
call the "GridView.DataBind" method in the DetailsView's "ItemInserted"
event to refresh the GridView (connected to a SqlDataSource):

============================
protected void DetailsView1_ItemInserted(object sender,
DetailsViewInsertedEventArgs e)
{
GridView1.DataBind();

}
==================

If you are programmatically get data through DataSource control, you can
also programmatically call DataSource.Select method to get the new value
(as long as you haven't enable cache on the datasource control) and assign
it to the target display control. e.g

==================
protected void DetailsView1_ItemInserted(object sender,
DetailsViewInsertedEventArgs e)
{
DataView dv =
SqlDataSource1.Select(DataSourceSelectArguments.Em pty) as DataView;
lblCount.Text = dv[0][0].ToString();
}
================

Hope this helps. Please feel free to let me know if there is anything I
missed or if you have any other questions.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.


Oct 30 '06 #3
Hello Steven,

Thanks for your help :)

Regards,
Asaf

"Steven Cheng[MSFT]" wrote:
Hello Asaf,

Are you use a SqlDatasource or ObjectDataSource control to retrieve the
Count of records in a table? Based on my understanding, only
ObjectDataSource can be configured to use TableAdapter component and
SqlDataSource will hide the code logic of underlying data accessing.

Also, after you have get the count data from
DataSourceControl(sqlDatasrouce or objectdatasource), how do you display
the value on control, use databinding (through DataSourceId) or manually
call DataSource.Select method and assign the return value to the target
control?

If you are using databinding approach, you just need to recall the
"DataBind" method of the target control(such as GridView ) after you've
peformed inserting or updating in the backend database. e.g.

suppose I use another DetailsView to insert data into backend data, I can
call the "GridView.DataBind" method in the DetailsView's "ItemInserted"
event to refresh the GridView (connected to a SqlDataSource):

============================
protected void DetailsView1_ItemInserted(object sender,
DetailsViewInsertedEventArgs e)
{
GridView1.DataBind();

}
==================

If you are programmatically get data through DataSource control, you can
also programmatically call DataSource.Select method to get the new value
(as long as you haven't enable cache on the datasource control) and assign
it to the target display control. e.g

==================
protected void DetailsView1_ItemInserted(object sender,
DetailsViewInsertedEventArgs e)
{
DataView dv =
SqlDataSource1.Select(DataSourceSelectArguments.Em pty) as DataView;
lblCount.Text = dv[0][0].ToString();
}
================

Hope this helps. Please feel free to let me know if there is anything I
missed or if you have any other questions.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.


Nov 1 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Wayne Wengert | last post by:
I have a menu that calls a specific asp page and passes a variable data1page.asp?year=2001 where the value of the year variable is determined in code. This works fine the first 2 times I...
4
by: mark | r | last post by:
anyone know how to update the inforation in a select box without refreshing the page or using massive javascript arrays using regular asp (not .net)? thanks mark
2
by: jdi | last post by:
Hello, I have a seemingly basic question about ASP.NET. I would like to create a page containing an image, which keeps swapping the url of the image source, without refreshing the entire page. ...
8
khalidbaloch
by: khalidbaloch | last post by:
hello dear friends this is my post in this forum and i hope for greate response .. for my php application i want when user checks a checkbox select element should be disabled and whehn user...
3
by: user | last post by:
Hi, let's say a page loads on a browser. Without refreshing the page, multiple textboxes within the page gets real time data @ a few seconds interval. what is the logic behind to achieve...
4
shoonya
by: shoonya | last post by:
can i change the url of any page from abc.php?foo=test1 --> abc.php?foo=test2 without refreshing the page? shoonya
5
by: rodeoval | last post by:
I need to have three drop down lists, but the dependent should get the values from the database without refreshing the page..If knows,someone pls reply soon
2
by: mukeshrasm | last post by:
Hi I am printing some text on image dynamically. I am setting the font size and type dynamically and then displaying to other page. Thing is that it is not displaying the image when I click submit...
9
by: Bali | last post by:
Default.aspx is the starting page containing a control(ascx) which has asp:button control on it. On the button click event it has to open a new page as a modal control. Since refreshing a page in a...
0
by: Bali | last post by:
Default.aspx is the starting page containing a control(ascx) which has asp:button control on it. On the button click event it has to open a new page as a modal control. Since refreshing a page in...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.