D
Diane
Hey-
I am having trouble with a simple datagrid example, and need some
advice if anyone is knowledgable. It's really driving me batty! I've
searched newsgroups and help sites but nobody seems to have an answer
that makes things work, although lots of folks seem to have had this
problem before.. It's funny how much time you can waste when you think
the answer is just around the corner!
Setup:
1 I have an ASP.NET page with a datagrid, autogenerate columns is
true, viewstate is enabled, and the DG has an Edit/Update/Cancel
button.
2. In Page_Load, I load up the DataGrid with data and bind it, only if
postback is false
3. In the EditCommand event, I set the edit item index to the row
selcted. I do not databind here.
Problem:
I have to click the edit link twice to make the row editable. If I
click once the page appears unchanged.
Since I CAN get the page to reload with the selected row editable after
two clicks, I figure that the DataGrid is saving the data to the
viewstate. So, I should not need to reload from the database or save
the dataset in the session or suchlike hack. I mean, that is what the
viewstate is for, right? It obviously knows how to refresh the DataGrid
from the viewstate.
But, if I call DataBind on the DataGrid again in the EditCommand
method, all the data in the grid dissapears (as I would expect, since
it has no datasource defined when I bind).
I'm almost thinking to tell my users to just click twice!
Does anyone have any ideas or suggestions (Besides "Enable Viewstate"
or "data bind in the Edit command method" or "store the dataset to the
session"?)
Thanks so much, I am delerious and heading off to bed now!
Diane
I am having trouble with a simple datagrid example, and need some
advice if anyone is knowledgable. It's really driving me batty! I've
searched newsgroups and help sites but nobody seems to have an answer
that makes things work, although lots of folks seem to have had this
problem before.. It's funny how much time you can waste when you think
the answer is just around the corner!
Setup:
1 I have an ASP.NET page with a datagrid, autogenerate columns is
true, viewstate is enabled, and the DG has an Edit/Update/Cancel
button.
2. In Page_Load, I load up the DataGrid with data and bind it, only if
postback is false
3. In the EditCommand event, I set the edit item index to the row
selcted. I do not databind here.
Problem:
I have to click the edit link twice to make the row editable. If I
click once the page appears unchanged.
Since I CAN get the page to reload with the selected row editable after
two clicks, I figure that the DataGrid is saving the data to the
viewstate. So, I should not need to reload from the database or save
the dataset in the session or suchlike hack. I mean, that is what the
viewstate is for, right? It obviously knows how to refresh the DataGrid
from the viewstate.
But, if I call DataBind on the DataGrid again in the EditCommand
method, all the data in the grid dissapears (as I would expect, since
it has no datasource defined when I bind).
I'm almost thinking to tell my users to just click twice!
Does anyone have any ideas or suggestions (Besides "Enable Viewstate"
or "data bind in the Edit command method" or "store the dataset to the
session"?)
Thanks so much, I am delerious and heading off to bed now!
Diane