Hi Team,
I'm facing with grid edit mode(InPlace or Popup or EditForm) is always auto fire when i press enter key in search text box. My grid is using OnNeedDataSource property. Problem is become from "RadAjaxManager". If i set setting at ajamanager
RadGrid Edit Form is auto fired. If i remove it, it's ok.
Code Aspx.
Code Behind
Anything wrong at my code. . Kindly please reply to me. Sorry! my title is wrong! Problem is "GridEditCommandColumn auto fire".
sample lnk :Sample Code
Regards,
I'm facing with grid edit mode(InPlace or Popup or EditForm) is always auto fire when i press enter key in search text box. My grid is using OnNeedDataSource property. Problem is become from "RadAjaxManager". If i set setting at ajamanager
<
telerik:AjaxSetting
AjaxControlID
=
"_btnSearch"
EventName
=
"OnClick"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadGrid1"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
Code Aspx.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
>Untitled Page</
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
autocomplete
=
"false"
>
<
div
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager"
runat
=
"server"
>
</
telerik:RadScriptManager
>
<!-- content start -->
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"_btnSearch"
EventName
=
"OnClick"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadGrid1"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadGrid1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadGrid1"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
telerik:RadAjaxLoadingPanel
ID
=
"RadAjaxLoadingPanel1"
runat
=
"server"
Skin
=
"Default"
>
</
telerik:RadAjaxLoadingPanel
>
<
telerik:RadAjaxPanel
ID
=
"RadAjaxPanel1"
runat
=
"server"
Height
=
"100%"
Width
=
"300px"
OnLoad
=
"RadAjaxPanel1_Load"
>
<
table
>
<
tr
>
<
td
style
=
"width: 150px;"
>
Search By</
td
>
<
td
style
=
"width: 5px;"
>
:</
td
>
<
td
style
=
"width: 150px;"
>
<
asp:DropDownList
ID
=
"_cboSearchBy"
runat
=
"server"
Width
=
"150px"
>
</
asp:DropDownList
>
</
td
>
<
td
style
=
"width: 25px"
>
<
asp:TextBox
ID
=
"_txtPrefix"
runat
=
"server"
Width
=
"25px"
AutoPostBack
=
"false"
AutoCompleteType
=
"none"
></
asp:TextBox
></
td
>
<
td
style
=
"width: 200px;"
>
<
asp:TextBox
ID
=
"_txtFind"
runat
=
"server"
Width
=
"200px"
AutoPostBack
=
"false"
AutoCompleteType
=
"none"
></
asp:TextBox
></
td
>
<
td
style
=
"width: 25px"
>
<
asp:TextBox
ID
=
"_txtSuffix"
runat
=
"server"
Width
=
"25px"
AutoPostBack
=
"false"
AutoCompleteType
=
"none"
></
asp:TextBox
></
td
>
<
td
style
=
"width: 50px"
>
<
asp:Button
ID
=
"_btnSearch"
runat
=
"server"
Text
=
"Search"
Width
=
"50px"
OnClick
=
"_btnSearch_Click"
/>
</
td
>
</
tr
>
</
table
>
</
telerik:RadAjaxPanel
>
<
telerik:RadGrid
ID
=
"RadGrid1"
Width
=
"97%"
AllowPaging
=
"True"
PageSize
=
"15"
runat
=
"server"
AllowSorting
=
"true"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
GridLines
=
"None"
OnItemCommand
=
"RadGrid1_ItemCommand"
>
<
MasterTableView
Width
=
"100%"
EditMode
=
""
AllowAutomaticUpdates
=
"false"
>
<
Columns
>
<
telerik:GridEditCommandColumn
ButtonType
=
"ImageButton"
UniqueName
=
"EditCommandColumn"
EditText
=
"Edit"
HeaderStyle-Width
=
"30"
ItemStyle-Width
=
"30"
HeaderStyle-HorizontalAlign
=
"center"
ItemStyle-HorizontalAlign
=
"center"
>
</
telerik:GridEditCommandColumn
>
</
Columns
>
</
MasterTableView
>
<
PagerStyle
Mode
=
"NextPrevAndNumeric"
/>
<
FilterMenu
EnableTheming
=
"True"
>
<
CollapseAnimation
Duration
=
"200"
Type
=
"OutQuint"
/>
</
FilterMenu
>
</
telerik:RadGrid
>
<!-- content end -->
</
div
>
</
form
>
</
body
>
</
html
>
Code Behind
public
DataTable GetDataTable(
string
query)
{
String ConnString = ConfigurationManager.ConnectionStrings[
"NorthwindConnectionString"
].ConnectionString;
SqlConnection conn =
new
SqlConnection(ConnString);
SqlDataAdapter adapter =
new
SqlDataAdapter();
adapter.SelectCommand =
new
SqlCommand(query, conn);
DataTable myDataTable =
new
DataTable();
conn.Open();
try
{
adapter.Fill(myDataTable);
}
finally
{
conn.Close();
}
return
myDataTable;
}
protected
void
RadGrid1_NeedDataSource(
object
source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
RadGrid1.DataSource = GetDataTable(
"SELECT CustomerID, CompanyName, ContactName, ContactTitle, Address, PostalCode FROM Customers"
);
}
protected
void
_btnSearch_Click(
object
sender, EventArgs e)
{
if
(_txtFind.Text.Trim()!=
""
)
RadGrid1.DataSource = GetDataTable(
"SELECT CustomerID, CompanyName, ContactName, ContactTitle, Address, PostalCode FROM Customers where CustomerID='"
+ _txtFind.Text.Trim() +
"'"
);
else
RadGrid1.DataSource = GetDataTable(
"SELECT CustomerID, CompanyName, ContactName, ContactTitle, Address, PostalCode FROM Customers"
);
RadGrid1.Rebind();
}
protected
void
RadAjaxPanel1_Load(
object
sender, EventArgs e)
{
}
protected
void
RadGrid1_ItemCommand(
object
sender, Telerik.Web.UI.GridCommandEventArgs e)
{
//e.Canceled = true;
}
Anything wrong at my code. . Kindly please reply to me. Sorry! my title is wrong! Problem is "GridEditCommandColumn auto fire".
sample lnk :Sample Code
Regards,