473,416 Members | 1,531 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,416 software developers and data experts.

Refreshing the DataGrid in a webform in the IFrame

Rod
I posted a message to this group yesterday asking how to pass parameters to
a web form that is the source of an IFrame on a parent web form. I've
gotten my answer, and it works. Thanks!

Now I have a different problem. The web form that is in the IFrame has a
DataGrid in it. I have a button column in it which I use to trigger the
deletion of the row in the database, and I want it to also reflect that
deletion in the data grid. The code in the datagrid's DeleteCommand event
is working fine, to delete the row in the database. However, even though I
call the data adapter's Fill method to repopulate the dataset, and then bind
the dataset again to the datagrid, it does not reflect the fact that the
data is now deleted. I have checked the data in the dataset itself, and
have verified that the record I wanted to delete is deleted, so why doesn't
it show that in the datagrid?

Rod
Nov 18 '05 #1
4 2101
Hi Rod,

From your description, you used a webform datagrid to display some datas
retrieved from database and the datagrid contains a delete columns to
delete the items. When after the deleting, you update the dataset to
theserver and refill the dataset and bind to the grid again. However, you
found the delelted rows still exist on the datagrid, yes?

As you mentioned that you have checked that the dataset's data has
represnent the correct updated result( no deleted rows) ,yes? Then, I think
the problem is likely due to the rebinding of the datagrid. How do you
rebind the dataset to the datagrid? Maybe it is not correctly rebinded.
Please have a check on it and also it'll be better that you provide some
detailed code snip on this. Thank.s

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #2
Rod
Hi Steve,

This particular application we're using VB.NET for the code behind language.
All of the code snippets I present here are from the web form which is the
target of the IFrame on the parent page.

In the page load event I have the following (this is all within a try-catch
block, which I've omitted for clarity's sake):

'now I have to build a SQL query using spNewVoucherServices20, to retrieve
data
SqlConnection1.ConnectionString = Session("ConnectionString").ToString()
'assign the connection string
SqlConnection1.Open()
ServicesForVoucher.Parameters("@ProviderNumber").V alue =
Convert.ToInt16(nProviderNumber)
ServicesForVoucher.Parameters("@VoucherNumber").Va lue = lVoucherNumber
ServicesForVoucher.Parameters("@ServiceCodeFilter" ).Value =
Convert.ToInt16(nServiceCodeFilter)

'fetch the data
daServicesForVoucher.Fill(DsServicesForVoucher1, "spNewVoucherServices20")

'bind it to the grid
DataGrid1.DataSource = DsServicesForVoucher1.spNewVoucherServices20
DataGrid1.DataBind()

(Please note that I do not consider postback in the page load event.
Basically I am thinking that I will always retrieve the data during each
postback.)

Then the code for the datagrid's delete command I have the following:

Try
DeleteService.Parameters("@ServiceID").Value = lServiceID
daServicesForVoucher.DeleteCommand.ExecuteNonQuery ()
cAmountExpended =
Convert.ToDecimal(DeleteService.Parameters("@Amoun tExpended").Value)
Catch ex As Exception
lblError.Text = ex.Message
lblError.Visible = True
End Try
daServicesForVoucher.Fill(DsServicesForVoucher1, "spNewVoucherServices20")
'refresh the data
DataGrid1.DataSource = DsServicesForVoucher1.spNewVoucherServices20
DataGrid1.DataBind() 'rebind after deleting the service

(Here you see that I am executing the DataBind() method of the datagrid
control, again. I thought this would work, even though it is called from
the page load event, because the datagrid's delete command event is fired
after the page load event.)

Rod

"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:g%****************@cpmsftngxa06.phx.gbl...
Hi Rod,

From your description, you used a webform datagrid to display some datas
retrieved from database and the datagrid contains a delete columns to
delete the items. When after the deleting, you update the dataset to
theserver and refill the dataset and bind to the grid again. However, you
found the delelted rows still exist on the datagrid, yes?

As you mentioned that you have checked that the dataset's data has
represnent the correct updated result( no deleted rows) ,yes? Then, I think the problem is likely due to the rebinding of the datagrid. How do you
rebind the dataset to the datagrid? Maybe it is not correctly rebinded.
Please have a check on it and also it'll be better that you provide some
detailed code snip on this. Thank.s

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #3
Hi Rod,

Thanks for the followup and the detailed code snippet. I've checked the
code and since you're using a strong type dataset and doing the update and
retrieving via DataAdapte and you mentioned that the records in the dataset
are the correct ones. So I don't think the problem is on the data
manipulcation with database server.

However, as you mentioned that

===================================
(Here you see that I am executing the DataBind() method of the datagrid
control, again. I thought this would work, even though it is called from
the page load event, because the datagrid's delete command event is fired
after the page load event.)
===================================

You put the datagrid's bind code in the Page_Load event handler which is
called before the datagrid's delete command event. I think this maybe the
cause of the problem, since you delete the record and update it to the
database in the DataGrid 's delete command event, you also need to refill
the dataset again in the delete command event. For example:

void dataGrid_Command(Object sender, DataGridCommandEventArgs e)
{

//1.delete the item in dataset
//2.update the dataset to database
//3.retrieve the data from database again(refill the dataset)
//4. set the new filled dataset to datagrid's DataSource and call
DataBind()

}

In addition, since the datagrid bydefault store the items(displaying
records) in its viewstate, we can only do inital databind in Page_Load
rather than everytime, such as

void Page_Load(...)
{
if(!IsPostBack)
{

//Bind data to datagrid
}
}
Please have a check. Hope helps.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx


Nov 18 '05 #4
Rod
HI Steven,

Thank you for the reply!

I found, thanks to your help, that I needed to purge the dataset of the data
retrieved in the page load event. So, after I deleted the data from the
table, I then called the Clear() method of the dataset against the relevant
table. This cleared the dataset of whatever was in it, and then I retrieved
the data from the database via the data adapter's Fill() method.

Rod

"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:ar**************@cpmsftngxa06.phx.gbl...
Hi Rod,

Thanks for the followup and the detailed code snippet. I've checked the
code and since you're using a strong type dataset and doing the update and
retrieving via DataAdapte and you mentioned that the records in the dataset are the correct ones. So I don't think the problem is on the data
manipulcation with database server.

However, as you mentioned that

===================================
(Here you see that I am executing the DataBind() method of the datagrid
control, again. I thought this would work, even though it is called from
the page load event, because the datagrid's delete command event is fired
after the page load event.)
===================================

You put the datagrid's bind code in the Page_Load event handler which is
called before the datagrid's delete command event. I think this maybe the
cause of the problem, since you delete the record and update it to the
database in the DataGrid 's delete command event, you also need to refill
the dataset again in the delete command event. For example:

void dataGrid_Command(Object sender, DataGridCommandEventArgs e)
{

//1.delete the item in dataset
//2.update the dataset to database
//3.retrieve the data from database again(refill the dataset)
//4. set the new filled dataset to datagrid's DataSource and call
DataBind()

}

In addition, since the datagrid bydefault store the items(displaying
records) in its viewstate, we can only do inital databind in Page_Load
rather than everytime, such as

void Page_Load(...)
{
if(!IsPostBack)
{

//Bind data to datagrid
}
}
Please have a check. Hope helps.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx



Nov 18 '05 #5

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

Similar topics

0
by: msnews | last post by:
Hi -- I'm very, very new to ASP.Net, and I've been trying for several days to figure out how to update a datagrid AND refresh it on the client side so that the page doesn't refresh. I've torn my...
2
by: Lubo¹ ©lapák | last post by:
Hi, I have a WebForm and in this WebForm i have IFRAME with name="obsah". How can I from C# code load a page into this IFRAME? Thanks Lubos
3
by: Aitham alama | last post by:
Hi There, My question is as following, I have a webform (Webform1) which contains one label control and command button, when the user clicks the button another webform (Webform2) appears,...
1
by: msuk | last post by:
All, I have a webform e.g. a.aspx that contains an a table of 2 cols 1 row. In col1 I have an IFRAME and in col2 I have some labels/text boxes. Now the IFRAME source is say 'b.aspx' that...
3
polymorphic
by: polymorphic | last post by:
I have succeeded in embedding PDF files in a dynamic iframe. The problem is that I need the PDF to cache. If the PDF remains the same from page load to page load then the pdf is somehow cached with...
6
by: bnashenas1984 | last post by:
Here you can see the script I found in google to refresh a page without hearing any click sound which is usual to hear when a link is clicked or a page is refreshed. <script...
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...
1
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...
1
by: bnashenas1984 | last post by:
Hi everyone I'v seen several websites doing what I'm asking now but I don't know how they do it. Lets say we have an E-commerce website that has a shopping cart inside an IFrame which shows what...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.