Datagrid EnableViewState OnItemCommand Problems

J

james

Hi

I disable the view state within my datagrids using the code below...

private void Page_PreRender(object sender, EventArgs e) {
foreach (DataGridItem dataGridItem in dgdData.Items)
dgdData.EnableViewState = false;
}

I also always include the add and details buttons to the datagrid
within a template column as below...

<asp:TemplateColumn>
<HeaderTemplate>
<asp:Button ID="btnAdd" runat="Server"
CommandName="Add" Style="width: 50px" Text="Add" />
</HeaderTemplate>
<ItemTemplate>
<asp:Button ID="btnDetails" runat="Server"
CommandName="Details" Style="width: 50px" Text="Details" />
</ItemTemplate>
</asp:TemplateColumn>

The problem that I am experiencing is that for some data grid views,
clicking on a button results in a postback and a call to the oncommand
member function, but not to the prerender. This is as expected.

For others, the postback is called, the oncommand member function is
not called, but the prerender function is. This seems bizarre.

Has anyone else come across this. Is is a Microsoft bug?

Regards

James
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top