as requested here are the files and this occurs on Telerik version 2010.1.519.35. you will notice the Context is used in the RadgridAddOnLoad.aspx.cs
and in ucManufacturerAccountEdit.ascx.cs
so basically, if I remove those instructions, the manufacturer combobox is not predefined with the valued specified by the value of the querystring (ie: RadgridAddOnLoad.aspx?mode=add&intManufacturerId=5). If I leave those instructions then the combobox is predefined.
the files
Data.xml
RadgridAddOnLoad.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RadgridAddOnLoad.aspx.cs" Inherits="test_RadgridAddOnLoad" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<
head
id
=
"Head1"
runat
=
"server"
>
<
title
></
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
/>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
/>
<
telerik:RadAjaxManagerProxy
ID
=
"RadAjaxManagerProxy1"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadAjaxManagerProxy1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"grdStore"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"grdStore"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"grdStore"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManagerProxy
>
<
telerik:RadAjaxLoadingPanel
runat
=
"server"
ID
=
"RadAjaxLoadingPanel1"
Height
=
"150px"
Width
=
"150px"
/>
<
telerik:RadScriptBlock
ID
=
"RadScriptBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function PopUpShowing(sender, eventArgs) {
var popUp = eventArgs.get_popUp();
var scrollTop = (typeof window.innerHeight != 'undefined' ? 0 : document.documentElement.scrollTop);
var popUpWidth = popUp.style.width.substr(0, popUp.style.width.indexOf("px"));
var popUpHeight = popUp.style.height.substr(0, popUp.style.height.indexOf("px"));
var windowHeight = (typeof window.innerHeight != 'undefined' ? window.innerHeight : document.body.offsetHeight - scrollTop);
var windowWidth = document.body.offsetWidth;
if (popUpHeight == "") popUpHeight = 300; // if the height isn't set on the popup, default to 300px
popUp.style.position = "fixed";
popUp.style.left = (Math.floor((windowWidth - popUpWidth) / 2)).toString() + "px";
popUp.style.top = (Math.floor((windowHeight - popUpHeight) / 2) + scrollTop).toString() + "px";
}
</
script
>
</
telerik:RadScriptBlock
>
<
asp:HiddenField
ID
=
"txtDealerGUID"
runat
=
"server"
/>
<
asp:HiddenField
ID
=
"txtAdministrationURL"
runat
=
"server"
/>
<
telerik:RadGrid
ID
=
"grdStore"
runat
=
"server"
GridLines
=
"None"
AllowPaging
=
"True"
AllowSorting
=
"True"
AllowFilteringByColumn
=
"true"
Width
=
"100%"
AutoGenerateColumns
=
"False"
OnPreRender
=
"grdStore_PreRender"
DataSourceID
=
"XmlDataSource1"
OnDeleteCommand
=
"grdStore_DeleteCommand"
OnItemDataBound
=
"grdStore_ItemDataBound"
OnUpdateCommand
=
"grdStore_UpdateCommand"
OnInsertCommand
=
"grdStore_InsertCommand"
OnItemCommand
=
"grdStore_ItemCommand"
OnItemCreated
=
"grdStore_ItemCreated"
AllowMultiRowEdit
=
"False"
AllowMultiRowSelection
=
"False"
>
<
ClientSettings
>
<
ClientEvents
OnPopUpShowing
=
"PopUpShowing"
/>
</
ClientSettings
>
<
MasterTableView
GridLines
=
"None"
Width
=
"100%"
DataKeyNames
=
"ID"
NoMasterRecordsText="<%$ Resources:Resource, lblNoRecordToDisplay%>" CommandItemDisplay="Top" CommandItemSettings-AddNewRecordText="Add" EditFormSettings-PopUpSettings-Modal="true" EditFormSettings-PopUpSettings-Height="200px" EditFormSettings-PopUpSettings-Width="730px" EditFormSettings-PopUpSettings-ZIndex="2999" EditMode="PopUp">
<
rowindicatorcolumn
visible
=
"False"
>
<
HeaderStyle
Width
=
"20px"
/>
</
rowindicatorcolumn
>
<
expandcollapsecolumn
resizable
=
"False"
visible
=
"False"
>
<
HeaderStyle
Width
=
"20px"
/>
</
expandcollapsecolumn
>
<
CommandItemSettings
RefreshImageUrl
=
"Refresh.gif"
/>
<
Columns
>
<
telerik:GridBoundColumn
SortExpression
=
"BusinessName"
HeaderText="<% $ Resources:Resource, lblStore %>" DataField="BusinessName" UniqueName="BusinessName" />
<
telerik:GridBoundColumn
SortExpression
=
"ManufacturerName"
HeaderText="<% $ Resources:Resource, lblManufacturer %>" DataField="ManufacturerName" UniqueName="ManufacturerName" />
<
telerik:GridBoundColumn
SortExpression
=
"Description"
HeaderText="<% $ Resources:Resource, lblDescription %>" DataField="Description" UniqueName="Description" />
<
telerik:GridBoundColumn
SortExpression
=
"PIN"
HeaderText="<% $ Resources:Resource, lblPIN %>" DataField="PIN" UniqueName="PIN" />
<
telerik:GridTemplateColumn
AllowFiltering
=
"false"
UniqueName
=
"Status"
HeaderText="<% $ Resources:Resource, lblStatus %>">
<
ItemTemplate
>
<
asp:Label
ID
=
"lblStatus"
runat
=
"server"
/>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridEditCommandColumn
UpdateText
=
"Update"
UniqueName
=
"EditCommandColumn"
CancelText
=
"Cancel"
EditText="<% $ Resources:Resource, lblEdit %>" />
<
telerik:GridButtonColumn
ConfirmText="<% $ Resources:Resource, lblDeleteConfirmation %>" UniqueName="DeleteColumn" Text="<%$ Resources:Resource, lblDelete%>" CommandName="Delete" />
</
Columns
>
<
EditFormSettings
UserControlName
=
"~/Controls/ucManufacturerAccountEdit.ascx"
EditFormType
=
"WebUserControl"
CaptionFormatString="<%$ Resources:Resource, lblAccounts%>" />
<
PagerStyle
Mode
=
"NextPrev"
/>
</
MasterTableView
>
</
telerik:RadGrid
>
<
asp:XmlDataSource
ID
=
"XmlDataSource1"
runat
=
"server"
DataFile
=
"~/test/data.xml"
>
</
asp:XmlDataSource
>
</
div
>
</
form
>
</
body
>
</
html
>
RadgridAddOnLoad.aspx.cs
using
System;
using
System.Collections;
using
System.Configuration;
using
System.Data;
using
System.Linq;
using
System.Web;
using
System.Web.Security;
using
System.Web.UI;
using
System.Web.UI.HtmlControls;
using
System.Web.UI.WebControls;
using
System.Web.UI.WebControls.WebParts;
using
System.Xml.Linq;
using
Tech2020.Business.BusinessLogicLayer;
using
Telerik.Web.UI;
using
System.Collections.Generic;
using
System.Xml;
public
partial
class
test_RadgridAddOnLoad : System.Web.UI.Page
{
#region " Events "
protected
void
Page_Load(
object
sender, EventArgs e)
{
}
protected
void
Page_PreInit(
object
sender, EventArgs e)
{
if
(!IsPostBack)
{
}
}
protected
void
grdStore_PreRender(
object
sender, System.EventArgs e)
{
if
(!
this
.IsPostBack)
{
if
(Request[
"mode"
] !=
null
&& Request[
"mode"
] ==
"add"
)
{
grdStore.MasterTableView.IsItemInserted =
true
;
}
grdStore.MasterTableView.Rebind();
}
}
protected
void
grdStore_ItemCommand(
object
source, GridCommandEventArgs e)
{
switch
(e.CommandName)
{
case
RadGrid.EditCommandName:
grdStore.MasterTableView.IsItemInserted =
false
;
break
;
case
RadGrid.InitInsertCommandName:
grdStore.MasterTableView.ClearEditItems();
if
(Request.QueryString[
"intManufacturerId"
] !=
null
)
{
e.Canceled =
true
;
e.Item.OwnerTableView.InsertItem();
var insertedItem = e.Item.OwnerTableView.GetInsertItem();
var control = insertedItem.FindControl(GridEditFormItem.EditFormUserControlID)
as
UserControl;
((HiddenField)control.FindControl(
"ManufacturerID"
)).Value = Request.QueryString[
"intManufacturerId"
];
}
break
;
}
}
protected
void
grdStore_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridCommandItem)
{
GridCommandItem item = (GridCommandItem)e.Item;
//hide refresh linkbutton
((LinkButton)item.FindControl(
"RebindGridButton"
)).Visible =
false
;
}
}
protected
void
grdStore_UpdateCommand(
object
source, GridCommandEventArgs e)
{
if
(e.Item
is
GridEditableItem)
{
// update record
}
}
protected
void
grdStore_InsertCommand(
object
source, GridCommandEventArgs e)
{
if
(e.Item
is
GridEditableItem)
{
// add record
}
}
protected
void
grdStore_DeleteCommand(
object
source, GridCommandEventArgs e)
{
// delete record
}
protected
void
grdStore_ItemCreated(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridEditFormInsertItem && e.Item.IsInEditMode)
{
if
(Request.QueryString[
"intManufacturerId"
] !=
null
)
{
var insertedItem = (GridEditFormInsertItem)e.Item;
var control = insertedItem.FindControl(GridEditFormItem.EditFormUserControlID)
as
UserControl;
((HiddenField)control.FindControl(
"ManufacturerID"
)).Value = Request.QueryString[
"intManufacturerId"
];
Context.Items[
"manufID"
] = Request.QueryString[
"intManufacturerId"
];
}
}
}
#endregion
}
ucManufacturerAccountEdit.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ucManufacturerAccountEdit.ascx.cs" Inherits="Controls_ucManufacturerAccountEdit" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<
asp:HiddenField
ID
=
"ManufacturerID"
runat
=
"server"
Value='<%# DataBinder.Eval( Container, "DataItem.ManufacturerID" ) %>' />
<
div
style
=
"padding:8px"
>
<
table
class
=
"gridUcSingleEdit"
>
<
tr
>
<
td
class
=
"label"
><
asp:Label
Text="<% $ Resources:Resource, lblStore %>" runat="server" /></
td
>
<
td
><
telerik:RadComboBox
ID
=
"txtBusiness"
runat
=
"server"
Width
=
"268px"
/></
td
>
<
td
class
=
"label"
><
asp:Label
Text="<% $ Resources:Resource, lblManufacturer %>" runat="server" /></
td
>
<
td
><
telerik:RadComboBox
ID
=
"txtManufacturer"
runat
=
"server"
Width
=
"268px"
/></
td
>
</
tr
>
<
tr
>
<
td
class
=
"label"
><
asp:Label
ID
=
"lblAccount"
Text="<% $ Resources:Resource, lblAccount %>" runat="server" /></
td
>
<
td
><
asp:TextBox
ID
=
"txtAccount"
Text='<%# DataBinder.Eval( Container, "DataItem.Account" ) %>' MaxLength="255" runat="server" Width="264px" /><
asp:TextBox
ID
=
"txtPIN"
Enabled
=
"false"
Visible
=
"false"
Text='<%# DataBinder.Eval( Container, "DataItem.PIN" ) %>' MaxLength="255" runat="server" Width="264px" /><
asp:RequiredFieldValidator
Display
=
"Dynamic"
ErrorMessage="<%$ Resources:Resource, lblRequired%>" ControlToValidate="txtAccount" runat="server" /></
td
>
<
td
class
=
"label"
><
asp:Label
Text="<% $ Resources:Resource, lblDescription %>" runat="server" /></
td
>
<
td
><
asp:TextBox
ID
=
"txtDescription"
TextMode
=
"MultiLine"
Text='<%# DataBinder.Eval( Container, "DataItem.Description" ) %>' MaxLength="255" Width="264px" runat="server" /><
asp:RequiredFieldValidator
Display
=
"Dynamic"
ErrorMessage="<%$ Resources:Resource, lblRequired%>" ControlToValidate="txtDescription" runat="server" /></
td
>
</
tr
>
<
tr
>
<
td
colspan
=
"2"
style
=
"padding-left:2px;"
><
asp:Label
CssClass
=
"txtRefused"
Text="<% $ Resources:Resource, lblAllFieldsRequired %>" runat="server" /></
td
>
<
td
colspan
=
"2"
align
=
"right"
style
=
"padding-right:14px;"
>
<
asp:button
id
=
"btnUpdate"
text
=
"Update"
runat
=
"server"
CssClass
=
"button"
CommandName
=
"Update"
Visible='<%# !(DataItem is Telerik.Web.UI.GridInsertionObject) %>'></
asp:button
>
<
asp:button
id
=
"btnInsert"
text
=
"Insert"
runat
=
"server"
CssClass
=
"button"
CommandName
=
"PerformInsert"
Visible='<%# DataItem is Telerik.Web.UI.GridInsertionObject %>'></
asp:button
>
<
asp:button
id
=
"btnCancel"
text
=
"Cancel"
runat
=
"server"
CssClass
=
"button"
causesvalidation
=
"False"
commandname
=
"Cancel"
></
asp:button
>
</
td
>
</
tr
>
</
table
>
</
div
>
ucManufacturerAccountEdit.ascx.cs
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
Tech2020.Business.BusinessLogicLayer;
public
partial
class
Controls_ucManufacturerAccountEdit : System.Web.UI.UserControl
{
private
Tech2020.Business.BusinessLogicLayer.Manufacturer _manufacturerBLL =
new
Manufacturer();
private
Common _common =
new
Common();
private
Tech2020.Business.BusinessLogicLayer.Business _businessBll =
new
Tech2020.Business.BusinessLogicLayer.Business();
public
object
DataItem {
get
;
set
; }
protected
void
Page_PreRender(
object
sender, EventArgs e)
{
txtManufacturer.DataSource = _manufacturerBLL.Get();
txtManufacturer.DataTextField =
"Name"
;
txtManufacturer.DataValueField =
"ID"
;
txtManufacturer.DataBind();
txtManufacturer.SelectedValue = (ManufacturerID.Value !=
""
? ManufacturerID.Value : txtManufacturer.Items[0].Value);
if
(Context.Items[
"manufID"
] !=
null
)
{
txtManufacturer.SelectedValue = Context.Items[
"manufID"
].ToString();
}
txtBusiness.DataSource = _businessBll.GetDealerStores(Convert.ToInt32(Session[
"DealerID"
]), Convert.ToInt32(Tech2020.Generic.Const.Const.Attribute.Business_Sale_Lead_Email), 0, 0, Convert.ToInt32(Session[
"LanguageID"
]));
txtBusiness.DataTextField =
"Name"
;
txtBusiness.DataValueField =
"ID"
;
txtBusiness.DataBind();
}
}