Ask a Question related to ASP.NET General, Design and Development.
-
S. Justin Gengo #1
Re: Datagrid / Postback Question
Craig,
1) Populate the data grid on page load only:
If Not IsPostBack Then
'---Populate your grid the first time.
End If
2) Delete the record and then repopulate the grid. (If you do this put the
routine that populates your grid into a subroutine and call that subroutine
in the IsPostBack area and call it again after you delete the data.
Sincerely,
--
S. Justin Gengo, MCP
Web Developer
Free code library at:
[url]www.aboutfortunate.com[/url]
"Out of chaos comes order."
Nietzche
"Craig S" <craig@removethis_birch.net> wrote in message
news:Osej5BeXDHA.1004@TK2MSFTNGP12.phx.gbl...about> I believe the problem is definately a lack of understanding on my partpopulates> how postbacks work, but here goes...
>
> In my Page_Load method I bind my data from a SQL database to a datagrid -
> works great... I've now created a button and in the OnClick method I do a
> "DELETE FROM tablename WHERE keyfield=" +variablename (deletes several
> records based on which checkboxes are checked in the datagrid).
>
> The problem is that when the page posts back, the DELETE happens in the
> database, but it obviously happens after the SELECT statement thatdeleted,> the datagrid. I check the DB contents and the records were indeed> but the datagrid is always one postback behind (If I post the page back
> AGAIN, it will get the update)
>
> What code can I add to make sure the datagrid gets bound AFTER the delete
> command happens?
>
> Thanks in advance!
> Craig
>
>
>
S. Justin Gengo Guest
-
Slow datagrid on postback
Hello there, I have a datagrid that has a select button (so the user can choose a row) and also uses the datagrid sort. If I have a smaller... -
UserControl inside of datagrid - loses its viewstate when datagrid is re-bound on postback
I have a simple usercontrol, a datepicker which contains 3 dropdownlist , it resides inside a datagrid column and i set the selecteddate property of... -
custom usercontrol inside of datagrid - loses its state/viewstate on re-bind/postback of the datagrid
I have a simple usercontrol, a datepicker which contains 3 dropdownlist , it resides inside a datagrid column and i set the selecteddate property of... -
Datagrid Postback
Hello all, I have a Datagrid on a page. 1 column is a template column with a checkbox (unbound). The rest of the columns are databound that are... -
Datagrid Postback issues
Hello all, I have a Datagrid on a page. 1 column is a template column with a checkbox (unbound). The rest of the columns are databound that are... -
Craig S #2
Re: Datagrid / Postback Question
Perfect... I'm still used to classic ASP and having to get adjusted :)
Your advice worked perfectly - thanks...
"S. Justin Gengo" <sjgengo@aboutfortunate.com> wrote in message
news:OJ7SsOeXDHA.384@TK2MSFTNGP12.phx.gbl...subroutine> Craig,
>
> 1) Populate the data grid on page load only:
>
> If Not IsPostBack Then
> '---Populate your grid the first time.
> End If
>
> 2) Delete the record and then repopulate the grid. (If you do this put the
> routine that populates your grid into a subroutine and call thatdatagrid -> in the IsPostBack area and call it again after you delete the data.
>
> Sincerely,
>
> --
> S. Justin Gengo, MCP
> Web Developer
>
> Free code library at:
> [url]www.aboutfortunate.com[/url]
>
> "Out of chaos comes order."
> Nietzche
>
>
> "Craig S" <craig@removethis_birch.net> wrote in message
> news:Osej5BeXDHA.1004@TK2MSFTNGP12.phx.gbl...> about> > I believe the problem is definately a lack of understanding on my part> > how postbacks work, but here goes...
> >
> > In my Page_Load method I bind my data from a SQL database to aa> > works great... I've now created a button and in the OnClick method I dodelete> populates> > "DELETE FROM tablename WHERE keyfield=" +variablename (deletes several
> > records based on which checkboxes are checked in the datagrid).
> >
> > The problem is that when the page posts back, the DELETE happens in the
> > database, but it obviously happens after the SELECT statement that> deleted,> > the datagrid. I check the DB contents and the records were indeed> > but the datagrid is always one postback behind (If I post the page back
> > AGAIN, it will get the update)
> >
> > What code can I add to make sure the datagrid gets bound AFTER the>> > command happens?
> >
> > Thanks in advance!
> > Craig
> >
> >
> >
>
Craig S Guest



Reply With Quote

