ItemCommand firing instead of SortCommand

S

Steven

Hi there,

I am having a weird problem. I have a datagrid with both an ItemCommand and
a SortCommand. It was working fine until a day ago. Now, whenever I click
a column to fire the SortCommand, the ItemCommand gets fired instead. In
the debugger, e.CommandName is equal to "Sort", even though it is being
handled by the ItemCommand event. If I remove the ItemCommand event
handler, it works fine, but as soon as I put it back in the same problem
occurs.

Any ideas would be greatly appreciated.

Thanks,

Steven
 
A

Alvin Bruney

the problem will lie in your initialize component section. It is daizy
chained to the wrong event. you can either re-chain it in code to the right
handler or use the property grid object event section to re-map the handler.
hth
 
S

Steven

Looks fine to me...

private void InitializeComponent()

{
this.productsGrid.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.productsGrid_ItemCommand);
this.productsGrid.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.productsGrid_PageIndexChanged);
this.productsGrid.SortCommand += new System.Web.UI.WebControls.DataGridSortCommandEventHandler(this.productsGrid_SortCommand);
this.Load += new System.EventHandler(this.Page_Load);

}
 
A

Alvin Bruney

Oh sorry, itemcommand fires first and then sortcommand fires after. If you
put a break point in your sort command, it will/should eventually fire. I'd
be happy to take a closer look if this doesn't work for you.

--


-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
Looks fine to me...

private void InitializeComponent()

{
this.productsGrid.ItemCommand += new
System.Web.UI.WebControls.DataGridCommandEventHandler(this.productsGrid_Item
Command);
this.productsGrid.PageIndexChanged += new
System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.productsGrid_
PageIndexChanged);
this.productsGrid.SortCommand += new
System.Web.UI.WebControls.DataGridSortCommandEventHandler(this.productsGrid_
SortCommand);
this.Load += new System.EventHandler(this.Page_Load);

}
 
S

Steven

Ahh. That solves the problem. Thanks!

Alvin Bruney said:
Oh sorry, itemcommand fires first and then sortcommand fires after. If you
put a break point in your sort command, it will/should eventually fire. I'd
be happy to take a closer look if this doesn't work for you.

--


-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
Looks fine to me...

private void InitializeComponent()

{
this.productsGrid.ItemCommand += new
System.Web.UI.WebControls.DataGridCommandEventHandler(this.productsGrid_Item
Command);
this.productsGrid.PageIndexChanged += new
System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.productsGrid_
PageIndexChanged);
this.productsGrid.SortCommand += new
System.Web.UI.WebControls.DataGridSortCommandEventHandler(this.productsGrid_
SortCommand);
this.Load += new System.EventHandler(this.Page_Load);

}
 

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,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top