R
RRB
Hello,
I have a postback issue concerning the Datagrid. I posted this problem
to several forums before and didn’t receive a single response from
anyone. I initially thought my issue was related to sorting but now
understand it as a larger issue. Here goes:
I have a Datagrid that for various business reasons has the following
relevant characteristics:
- It does not keep viewstate
- It has template columns, manually generated
- it supports in-place editing (which cells are editable varies by
row-type).
- it supports column sorting by clickable column headers.
It is in implementing the column-sorting that I ran into trouble. From
what I have determined, once you databind the datagrid upon postback,
the datagrid becomes immutable from postback event handlers.
The normal flow is as follows:
Upon postback I manually add my columns, then set my grid datasource to
a session-cached DataView. Next, I call DataBind() on my grid.
Next, the column header’s click event fires and in the event handler, I
determine the sort order and set the sort property of my dataview.
Finally, I call DataBind() on the grid again.
Result: The grid displays as if I had not clicked a column header. And
if I click another column header, I will then see the grid sorted by the
column I’d previously clicked. The apparent behavior is that that the
grid is ignoring the second databind, as no exception is being thrown.
===========================
Test 1:
1. Upon postback, I manually add my columns, then set my grid datasource
to a session-cached DataView. Next, I call DataBind() on my grid.
1A. Next, I set the grid datasource to a simple string array, and call
DataBind() on the grid again.
2. Next, the column header’s click event fires and in the event handler,
I determine the sort order and set the sort property of my dataview.
Finally, I call DataBind() on the grid again.
Result: The grid displays empty rows (once for each string in my string
array) since my data didn’t match my columns. Thus my second databind
was successful.
===========================
Test 2:
1. Upon postback, I manually add my columns, then set my grid datasource
to a session-cached DataView. Next, I call DataBind() on my grid.
2. Next, the column header’s click event fires.
2A. In the event handler, I set the grid datasource to a simple string
array, and call DataBind() on the grid again. All other code is
commented out.
Result: The grid displays as if I had not clicked a column header. And
if I click another column header, I will then see the grid sorted by the
column I’d previously clicked. My second databind was NOT successful.
===========================
All I have changed between Test 1 and Test 2 is where I do the second
databind. In Test 1, I perform it in Page_Load before the click event is
fired. In Test 2, I perform it afterward in the click event handler.
Any insight on this issue would be of immense help! Thank you in
advance.
I have a postback issue concerning the Datagrid. I posted this problem
to several forums before and didn’t receive a single response from
anyone. I initially thought my issue was related to sorting but now
understand it as a larger issue. Here goes:
I have a Datagrid that for various business reasons has the following
relevant characteristics:
- It does not keep viewstate
- It has template columns, manually generated
- it supports in-place editing (which cells are editable varies by
row-type).
- it supports column sorting by clickable column headers.
It is in implementing the column-sorting that I ran into trouble. From
what I have determined, once you databind the datagrid upon postback,
the datagrid becomes immutable from postback event handlers.
The normal flow is as follows:
Upon postback I manually add my columns, then set my grid datasource to
a session-cached DataView. Next, I call DataBind() on my grid.
Next, the column header’s click event fires and in the event handler, I
determine the sort order and set the sort property of my dataview.
Finally, I call DataBind() on the grid again.
Result: The grid displays as if I had not clicked a column header. And
if I click another column header, I will then see the grid sorted by the
column I’d previously clicked. The apparent behavior is that that the
grid is ignoring the second databind, as no exception is being thrown.
===========================
Test 1:
1. Upon postback, I manually add my columns, then set my grid datasource
to a session-cached DataView. Next, I call DataBind() on my grid.
1A. Next, I set the grid datasource to a simple string array, and call
DataBind() on the grid again.
2. Next, the column header’s click event fires and in the event handler,
I determine the sort order and set the sort property of my dataview.
Finally, I call DataBind() on the grid again.
Result: The grid displays empty rows (once for each string in my string
array) since my data didn’t match my columns. Thus my second databind
was successful.
===========================
Test 2:
1. Upon postback, I manually add my columns, then set my grid datasource
to a session-cached DataView. Next, I call DataBind() on my grid.
2. Next, the column header’s click event fires.
2A. In the event handler, I set the grid datasource to a simple string
array, and call DataBind() on the grid again. All other code is
commented out.
Result: The grid displays as if I had not clicked a column header. And
if I click another column header, I will then see the grid sorted by the
column I’d previously clicked. My second databind was NOT successful.
===========================
All I have changed between Test 1 and Test 2 is where I do the second
databind. In Test 1, I perform it in Page_Load before the click event is
fired. In Test 2, I perform it afterward in the click event handler.
Any insight on this issue would be of immense help! Thank you in
advance.