ViewState Does not Persist with Named DataGrid Item

T

Trevor Benedict R

Hi,
I have a DataGrid that is databound. In the Item Created event, one of
my developers has set the ID Property to a name. On the client side,
there is code to refer to the TR tag so as to format and print the data
in the datagrid. While the ID is set in the ItemCreated event, the
postback event does not fire. I know that it is because of the name, I
am not sure as to how to set the name to its default value such that the
server side events fire normally and ViewState gets persisited. Any help
would be appreciated.

Regards,

Trevor Benedict R
 
E

Eliyahu Goldin

Trevor Benedict R,

What postback event are you talking about? Why should it be affected by the
name? What name? The id? On client side the rows get automatically generated
client ids. Please elaborate.

Eliyahu
 
T

Trevor Benedict R

Here is a detailed description. I have a DataGrid called dgMain. It is
databound only when the page is loaded first. In the ItemCreated event,
I have a code that looks like this. The idea is to get the same client
side

Private Sub dgMain_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
dgMain.ItemCreated
e.Item.ID = "myRow"
End Sub

When I do this, the datagrid loses its state, meaning the EditCommand
does not work and subsequently the grid does not display itself even
though the ViewState is set to persist both for the datagrid.

Why do I need to add an ID to the DataRow. This is because I have some
complex client side script that is used for formatting the datagrid and
printing it. I need to rollout this application withtin the next 3 days
without enough time to work on a workaround. If you know why I am taking
this shortcut, else I change the client side code to work based on the
Server Generated Tag.

Why would they allow this property to be altered if it would cause the
ViewState to be lost. So there should be an event where we restore it
back to it previous state so that Server Side events are triggered just
like dynamically loaded controls. I am just stumped for this particular
case.

Regards

Trevor Benedict R
MCSD
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top