EditCommandColumn not genereting correct events

J

Jaime

Hi all,

I have a datagrid with 2 databound columns and one EditCommandColumn, now
when I press the edit link, the correct OnEditCommand event is generated and
my user defined function is called (I'm sepcifying the name of the function
in the datagrid OnEditCommand="OnEdit"). Now the problem is that when I
press the update linkbutton, the datagrid calls my OnEdit function and when
I press the cancel linkbutton, the datagrid calls nothing in my code and it
cancels the edit mode.... One more thing, every event, the OnCommand handler
is called except the OnCancel...

Any help?

Here's the definiction of the datagrid

<asp:DataGrid ID="CuentasDG"
HorizontalAlign="Center"
AutoGenerateColumns="False"
CellPadding="3"
OnUpdateCommand="Cuentas_OnUpdate"
OnCancelCommand="Cuentas_OnCancel"
OnItemDataBound="Cuentas_OnItemDataBound"
OnEditCommand="Cuentas_OnEdit"
OnItemCommand="Cuentas_OnCommand"
Runat="server" >

And each Cuentas_On... is defined as:
protected void Cuentas_OnEdit( object sender, DataGridCommandEventArgs e )

protected void Cuentas_OnUpdate( object sender, DataGridCommandEventArgs e )

protected void Cuentas_OnCancel( object sender, DataGridCommandEventArgs e )

protected void Cuentas_OnCommand( object sender, DataGridCommandEventArgs
e )
 
Y

Yunus Emre ALPÖZEN [MCAD.NET]

every time itemcommand is called but u can control flow by checkin
commandname identifies command. And the other question,
Are u sure you give true command names for link buttons causes datagrid
events ???
 
E

Elton W

It seems that the viewstate of the datagrid is false.
Disabled viewstate often causes the datagrid not work
properly.

HTH

Elton Wang
(e-mail address removed)
 
J

Jaime

Hi,

Well actually I'm using

<asp:EditCommandColumn EditText="Edit" CancelText="Cancel"
UpdateText="Update" HeaderText="Edit" />

to generate the linkbuttons....

I've some more details....

I'm using my own page template framework and this is what seems to be
causing the problem, but I can't figure out why. my template framework is
something like:

public class BasePage : System.Web.Ui.Page
{
public BasePage()
{}

protected override void OnLoad(EventArgs e)
{
this.Controls.AddAt( 0, LoadControl( "Header.ascx" ) );
base.OnLoad( e );
this.Controls.Add( LoadControl( "Footer.ascx: ) );
}
}

and the derived page is

public class MyPage : BasePage
{
private void Page_Load(...)
{
if( !IsPostBack )
BindData()
}

protected BindData()
{
// get the data from the database
}

public void OnUpdate(...)
{
// this one never gets called
}
}
 

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,982
Messages
2,570,186
Members
46,739
Latest member
Clint8040

Latest Threads

Top