By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,948 Members | 1,570 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,948 IT Pros & Developers. It's quick & easy.

issue with overriding ProcessCmdKey() in DataGrid

P: n/a
Hello. I have wrapped the DataGrid control with my own class (SmartDataGrid)
adding some necessary functionality. My current webform has 2
SmartDataGrids. The first is populated by selected information from a drop
down box. The second datagrid is populated by viewing details from a row of
the first datagrid.

When editing individual rows (in either datagrid), clicking the enter key in
any editable textbox calls my inital search function that populates my first
datagrid. I want the enter key to tab to the next location. yes, simple!

All the documentation I've come across tells me to override the
ProcessCmdKey(). So I did just that. Here is my code...
public class SmartDataGrid : System.Web.UI.WebControls.DataGrid
{
override protected bool ProcessCmdKey(ref System.Windows.Forms.Message msg,
System.Windows.Forms.Keys keyData)
{
if(msg.WParam.ToInt32() == (int) Keys.Enter)
{
SendKeys.Send("{Tab}");
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
}

The error i'm getting is "no suitable method found to override". I have
found this article (HOW TO: Trap Keystrokes:
http://support.microsoft.com/kb/320584/EN-US/) in the KB and the one HUGE
difference is that their example overrides the
"System.Windows.Forms.DataGrid". I'm overriding the
"System.Web.UI.WebControls.DataGrid". If i change from one to the other then
i have 3 different overrides that give me the same error (the ProcessCmdKey
acutally compiles in this case).

I've run out of ideaRs..........
thanks for your help in advance...

--
jibran :^).

Nov 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
in the web version of the grid, the keystrokes happen on the client unknown
to the server, so this methods don't exist. what you want done has to be
done with client script. any javascript book will give enough info to do
this.

-- bruce (sqlwork.com)

"jibran" <ji****@discussions.microsoft.com> wrote in message
news:A1**********************************@microsof t.com...
Hello. I have wrapped the DataGrid control with my own class
(SmartDataGrid)
adding some necessary functionality. My current webform has 2
SmartDataGrids. The first is populated by selected information from a
drop
down box. The second datagrid is populated by viewing details from a row
of
the first datagrid.

When editing individual rows (in either datagrid), clicking the enter key
in
any editable textbox calls my inital search function that populates my
first
datagrid. I want the enter key to tab to the next location. yes, simple!

All the documentation I've come across tells me to override the
ProcessCmdKey(). So I did just that. Here is my code...
public class SmartDataGrid : System.Web.UI.WebControls.DataGrid
{
override protected bool ProcessCmdKey(ref System.Windows.Forms.Message
msg,
System.Windows.Forms.Keys keyData)
{
if(msg.WParam.ToInt32() == (int) Keys.Enter)
{
SendKeys.Send("{Tab}");
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
}

The error i'm getting is "no suitable method found to override". I have
found this article (HOW TO: Trap Keystrokes:
http://support.microsoft.com/kb/320584/EN-US/) in the KB and the one HUGE
difference is that their example overrides the
"System.Windows.Forms.DataGrid". I'm overriding the
"System.Web.UI.WebControls.DataGrid". If i change from one to the other
then
i have 3 different overrides that give me the same error (the
ProcessCmdKey
acutally compiles in this case).

I've run out of ideaRs..........
thanks for your help in advance...

--
jibran :^).

Nov 19 '05 #2

P: n/a
thanks bruce. duh! ok that makes sense. about the javascript: i actually
have already done that. here's the function...(instead of tabbing this one
clicks the update button of the currrent editable row).

however, my issue still exists. even after my Update_Command() function is
called my initial search function (btnSite_Click()) is called as well. I can
place break points in both and within one request both breakpoints are hit.

function ProcessCmdKey(event,id)
{
var key=event.keyCode;
if(key==13) //check for the return key...
{
alert("you've hit the enter key...");
document.getElementById(id).click();
}
}
--
jibran :^).

"Bruce Barker" wrote:
in the web version of the grid, the keystrokes happen on the client unknown
to the server, so this methods don't exist. what you want done has to be
done with client script. any javascript book will give enough info to do
this.

-- bruce (sqlwork.com)

"jibran" <ji****@discussions.microsoft.com> wrote in message
news:A1**********************************@microsof t.com...
Hello. I have wrapped the DataGrid control with my own class
(SmartDataGrid)
adding some necessary functionality. My current webform has 2
SmartDataGrids. The first is populated by selected information from a
drop
down box. The second datagrid is populated by viewing details from a row
of
the first datagrid.

When editing individual rows (in either datagrid), clicking the enter key
in
any editable textbox calls my inital search function that populates my
first
datagrid. I want the enter key to tab to the next location. yes, simple!

All the documentation I've come across tells me to override the
ProcessCmdKey(). So I did just that. Here is my code...
public class SmartDataGrid : System.Web.UI.WebControls.DataGrid
{
override protected bool ProcessCmdKey(ref System.Windows.Forms.Message
msg,
System.Windows.Forms.Keys keyData)
{
if(msg.WParam.ToInt32() == (int) Keys.Enter)
{
SendKeys.Send("{Tab}");
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
}

The error i'm getting is "no suitable method found to override". I have
found this article (HOW TO: Trap Keystrokes:
http://support.microsoft.com/kb/320584/EN-US/) in the KB and the one HUGE
difference is that their example overrides the
"System.Windows.Forms.DataGrid". I'm overriding the
"System.Web.UI.WebControls.DataGrid". If i change from one to the other
then
i have 3 different overrides that give me the same error (the
ProcessCmdKey
acutally compiles in this case).

I've run out of ideaRs..........
thanks for your help in advance...

--
jibran :^).


Nov 19 '05 #3

P: n/a
the enter key fires a postback, unless client code captures it and cancels
the event.

-- bruce (sqlwork.com)
"jibran" <ji****@discussions.microsoft.com> wrote in message
news:1F**********************************@microsof t.com...
thanks bruce. duh! ok that makes sense. about the javascript: i
actually
have already done that. here's the function...(instead of tabbing this
one
clicks the update button of the currrent editable row).

however, my issue still exists. even after my Update_Command() function
is
called my initial search function (btnSite_Click()) is called as well. I
can
place break points in both and within one request both breakpoints are
hit.

function ProcessCmdKey(event,id)
{
var key=event.keyCode;
if(key==13) //check for the return key...
{
alert("you've hit the enter key...");
document.getElementById(id).click();
}
}
--
jibran :^).

"Bruce Barker" wrote:
in the web version of the grid, the keystrokes happen on the client
unknown
to the server, so this methods don't exist. what you want done has to be
done with client script. any javascript book will give enough info to do
this.

-- bruce (sqlwork.com)

"jibran" <ji****@discussions.microsoft.com> wrote in message
news:A1**********************************@microsof t.com...
> Hello. I have wrapped the DataGrid control with my own class
> (SmartDataGrid)
> adding some necessary functionality. My current webform has 2
> SmartDataGrids. The first is populated by selected information from a
> drop
> down box. The second datagrid is populated by viewing details from a
> row
> of
> the first datagrid.
>
> When editing individual rows (in either datagrid), clicking the enter
> key
> in
> any editable textbox calls my inital search function that populates my
> first
> datagrid. I want the enter key to tab to the next location. yes,
> simple!
>
> All the documentation I've come across tells me to override the
> ProcessCmdKey(). So I did just that. Here is my code...
>
>
> public class SmartDataGrid : System.Web.UI.WebControls.DataGrid
> {
> override protected bool ProcessCmdKey(ref
> System.Windows.Forms.Message
> msg,
> System.Windows.Forms.Keys keyData)
> {
> if(msg.WParam.ToInt32() == (int) Keys.Enter)
> {
> SendKeys.Send("{Tab}");
> return true;
> }
> return base.ProcessCmdKey(ref msg, keyData);
> }
> }
>
> The error i'm getting is "no suitable method found to override". I
> have
> found this article (HOW TO: Trap Keystrokes:
> http://support.microsoft.com/kb/320584/EN-US/) in the KB and the one
> HUGE
> difference is that their example overrides the
> "System.Windows.Forms.DataGrid". I'm overriding the
> "System.Web.UI.WebControls.DataGrid". If i change from one to the
> other
> then
> i have 3 different overrides that give me the same error (the
> ProcessCmdKey
> acutally compiles in this case).
>
> I've run out of ideaRs..........
> thanks for your help in advance...
>
> --
> jibran :^).
>


Nov 19 '05 #4

P: n/a
Hi Bruce. I'm undertanding what i need to do. I have added a startup script
to my form with this line:

Page.RegisterOnSubmitStatement("submit","return DisallowEnterKey(event);");

here is my javascript function.

function DisallowEnterKey(event)
{
alert("key kode in DisallowEnterKey(): "+event.keyCode);
if(event.keyCode==13)
return false;
}

however, everytime the function is called the keyCode is always 0. it is
never 13 when i hit the enter key. Any ideas?
thanks
jibran

--
jibran :^).

"Bruce Barker" wrote:
the enter key fires a postback, unless client code captures it and cancels
the event.

-- bruce (sqlwork.com)
"jibran" <ji****@discussions.microsoft.com> wrote in message
news:1F**********************************@microsof t.com...
thanks bruce. duh! ok that makes sense. about the javascript: i
actually
have already done that. here's the function...(instead of tabbing this
one
clicks the update button of the currrent editable row).

however, my issue still exists. even after my Update_Command() function
is
called my initial search function (btnSite_Click()) is called as well. I
can
place break points in both and within one request both breakpoints are
hit.

function ProcessCmdKey(event,id)
{
var key=event.keyCode;
if(key==13) //check for the return key...
{
alert("you've hit the enter key...");
document.getElementById(id).click();
}
}
--
jibran :^).

"Bruce Barker" wrote:
in the web version of the grid, the keystrokes happen on the client
unknown
to the server, so this methods don't exist. what you want done has to be
done with client script. any javascript book will give enough info to do
this.

-- bruce (sqlwork.com)

"jibran" <ji****@discussions.microsoft.com> wrote in message
news:A1**********************************@microsof t.com...
> Hello. I have wrapped the DataGrid control with my own class
> (SmartDataGrid)
> adding some necessary functionality. My current webform has 2
> SmartDataGrids. The first is populated by selected information from a
> drop
> down box. The second datagrid is populated by viewing details from a
> row
> of
> the first datagrid.
>
> When editing individual rows (in either datagrid), clicking the enter
> key
> in
> any editable textbox calls my inital search function that populates my
> first
> datagrid. I want the enter key to tab to the next location. yes,
> simple!
>
> All the documentation I've come across tells me to override the
> ProcessCmdKey(). So I did just that. Here is my code...
>
>
> public class SmartDataGrid : System.Web.UI.WebControls.DataGrid
> {
> override protected bool ProcessCmdKey(ref
> System.Windows.Forms.Message
> msg,
> System.Windows.Forms.Keys keyData)
> {
> if(msg.WParam.ToInt32() == (int) Keys.Enter)
> {
> SendKeys.Send("{Tab}");
> return true;
> }
> return base.ProcessCmdKey(ref msg, keyData);
> }
> }
>
> The error i'm getting is "no suitable method found to override". I
> have
> found this article (HOW TO: Trap Keystrokes:
> http://support.microsoft.com/kb/320584/EN-US/) in the KB and the one
> HUGE
> difference is that their example overrides the
> "System.Windows.Forms.DataGrid". I'm overriding the
> "System.Web.UI.WebControls.DataGrid". If i change from one to the
> other
> then
> i have 3 different overrides that give me the same error (the
> ProcessCmdKey
> acutally compiles in this case).
>
> I've run out of ideaRs..........
> thanks for your help in advance...
>
> --
> jibran :^).
>


Nov 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.