<
telerik:RadGrid
ID
=
"RadGridProducts"
AllowSorting
=
"True"
AllowFilteringByColumn
=
"true"
DataSourceID
=
"ObjDSProducts"
AutoGenerateColumns
=
"false"
ShowStatusBar
=
"true"
CommandItemDisplay
=
"Top"
AllowAutomaticDeletes
=
"True"
AllowAutomaticInserts
=
"True"
AllowPaging
=
"True"
PageSize
=
"10"
runat
=
"server"
GridLines
=
"None"
Width
=
"100%"
EnableLinqExpressions
=
"false"
>
<
PagerStyle
Mode
=
"NextPrevAndNumeric"
></
PagerStyle
>
<
MasterTableView
DataKeyNames
=
"Product_ID"
AlternatingItemStyle-VerticalAlign
=
"Top"
ItemStyle-VerticalAlign
=
"Top"
CommandItemDisplay
=
"Top"
>
<
CommandItemSettings
AddNewRecordImageUrl
=
"~/connexassets/images/space.gif"
AddNewRecordText
=
""
ShowExportToExcelButton
=
"true"
/>
<
Columns
>
<
telerik:GridTemplateColumn
DataField
=
"Image"
HeaderText
=
"Image"
AllowFiltering
=
"false"
UniqueName
=
"Image"
HeaderStyle-Width
=
"45px"
SortExpression
=
"Group_Name"
>
<
ItemTemplate
><
asp:Image
runat
=
"server"
ID
=
"PrdImg"
ImageUrl='<%# String.Format("productresize.aspx?filename={0}&
width
=
55
", Eval("Image").ToString()) %>' Width="45px" BorderWidth="0" /></
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"Product_Code"
DataField
=
"Code"
HeaderText
=
"Code"
AllowFiltering
=
"false"
HeaderStyle-Width
=
"75px"
/>
<
telerik:GridTemplateColumn
AllowFiltering
=
"true"
DataField
=
"Product_Title"
HeaderText
=
"Title"
UniqueName
=
"Product_Title"
HeaderStyle-Width
=
"225px"
SortExpression
=
"Product_Title"
>
<
FilterTemplate
>
<
telerik:RadComboBox
ID
=
"RadComboBoxTitle"
DataSourceID
=
"SqlTitleDS"
DataTextField
=
"Product_Title"
DataValueField
=
"Product_Title"
Height
=
"200px"
DropDownWidth
=
"390px"
Filter
=
"StartsWith"
Width
=
"220px"
AppendDataBoundItems
=
"true"
SelectedValue='<%# TryCast(Container,GridItem).OwnerTableView.GetColumn("Product_Title").CurrentFilterValue %>'
runat="server" OnClientSelectedIndexChanged="Product_TitleIndexChanged">
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"All"
/>
</
Items
>
</
telerik:RadComboBox
>
<
telerik:RadScriptBlock
ID
=
"RadScriptBlockTitle"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function Product_TitleIndexChanged(sender, args) {
var tableView = $find("<%# TryCast(Container,GridItem).OwnerTableView.ClientID %>");
tableView.filter("Product_Title", args.get_item().get_value(), "EqualTo");
}
</
script
>
</
telerik:RadScriptBlock
>
</
FilterTemplate
>
<
ItemTemplate
>
<%#Eval("Product_Title")%>
<
br
/><
asp:Label
ID
=
"lblProduct"
Font-Bold
=
"true"
Font-Size
=
"Smaller"
Visible
=
"true"
runat
=
"server"
Text
=
""
></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
DataField
=
"Product_Details"
HeaderText
=
"Details"
SortExpression
=
"Product_Details"
UniqueName
=
"Product_Details"
Visible
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"Product_Price"
DataField
=
"Product_Price"
HeaderText
=
"Price"
AllowFiltering
=
"false"
HeaderStyle-Width
=
"60px"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblShowWeb"
Visible
=
"true"
runat
=
"server"
Text
=
""
/>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
AllowFiltering
=
"true"
DataField
=
"Brand_Title"
HeaderText
=
"Brand"
UniqueName
=
"Brand_Title"
HeaderStyle-Width
=
"80px"
SortExpression
=
"Brand_Title"
>
<
FilterTemplate
>
<
telerik:RadComboBox
ID
=
"RadComboBoxBrand"
DataSourceID
=
"SqlBrandDS"
DataTextField
=
"Brand_Title"
DataValueField
=
"Brand_Title"
Height
=
"200px"
DropDownWidth
=
"215px"
Width
=
"165px"
AppendDataBoundItems
=
"true"
SelectedValue='<%# TryCast(Container,GridItem).OwnerTableView.GetColumn("Brand_Title").CurrentFilterValue %>'
runat="server" OnClientSelectedIndexChanged="Brand_NameIndexChanged">
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"All"
/>
</
Items
>
</
telerik:RadComboBox
>
<
telerik:RadScriptBlock
ID
=
"RadScriptBlockBrand"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function Brand_NameIndexChanged(sender, args) {
var tableView = $find("<%# TryCast(Container,GridItem).OwnerTableView.ClientID %>");
tableView.filter("Brand_Title", args.get_item().get_value(), "EqualTo");
}
</
script
>
</
telerik:RadScriptBlock
>
</
FilterTemplate
>
<
ItemTemplate
><%#Eval("Brand_Title")%></
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"ProductEditOptions"
HeaderText
=
""
HeaderStyle-Width
=
"65px"
AllowFiltering
=
"false"
>
<
ItemTemplate
>
<
asp:ImageButton
ID
=
"imgButEdit"
runat
=
"server"
CausesValidation
=
"true"
AlternateText
=
"Edit Product"
CommandArgument='<%# Bind("Product_ID") %>' CommandName="Edit" ImageUrl="~/ConnexAssets/images/view.gif" />
<
asp:ImageButton
ID
=
"imgbutdele"
CommandArgument='<%# Bind("Product_ID") %>' runat="server" ImageUrl="~/ConnexAssets/images/delete.gif" OnClientClick="javascript:return confirm('Are you sure you want to permanently delete this product?');" CommandName="DeleteProduct" />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
<
DetailTables
>
<
telerik:GridTableView
DataKeyNames
=
"Prod_ID, Rel_ID"
DataSourceID
=
"DSRelated"
Width
=
"100%"
runat
=
"server"
CommandItemSettings-AddNewRecordText
=
"Add Related Product"
CommandItemDisplay
=
"Top"
ShowHeader
=
"false"
AllowFilteringByColumn
=
"false"
Name
=
"Child"
>
<
NoRecordsTemplate
>No Related Products listed....</
NoRecordsTemplate
>
<
ParentTableRelation
>
<
telerik:GridRelationFields
DetailKeyField
=
"Prod_ID"
MasterKeyField
=
"Product_ID"
/>
</
ParentTableRelation
>
<
AlternatingItemStyle
BackColor
=
"AliceBlue"
/>
<
Columns
>
<
telerik:GridBoundColumn
SortExpression
=
"RelatedProdName"
ReadOnly
=
"true"
HeaderText
=
"Related Product"
Visible
=
"true"
HeaderButtonType
=
"TextButton"
DataField
=
"RelatedProdName"
UniqueName
=
"RelatedProdName"
/>
<
telerik:GridButtonColumn
ConfirmText
=
"Delete this Related Product?"
ButtonType
=
"ImageButton"
CommandName
=
"Delete"
Text
=
"Delete"
UniqueName
=
"DeleteColumn2"
>
<
HeaderStyle
Width
=
"20px"
/>
<
ItemStyle
HorizontalAlign
=
"Center"
CssClass
=
"MyImageButton"
/>
</
telerik:GridButtonColumn
>
</
Columns
>
<
SortExpressions
>
<
telerik:GridSortExpression
FieldName
=
"RelatedProdName"
SortOrder
=
"Descending"
></
telerik:GridSortExpression
>
</
SortExpressions
>
<
EditFormSettings
EditFormType
=
"Template"
>
<
FormTemplate
>
<
table
id
=
"Table2"
cellspacing
=
"2"
cellpadding
=
"1"
width
=
"100%"
border
=
"0"
rules
=
"none"
style
=
"border-collapse: collapse; background: white;"
>
<
tr
>
<
td
>
<
table
id
=
"Table3"
cellspacing
=
"1"
cellpadding
=
"1"
border
=
"0"
>
<
tr
><
td
colspan
=
"2"
></
td
></
tr
>
<
tr
>
<
td
valign
=
"top"
>Product:</
td
>
<
td
>
<
asp:DropDownList
ID
=
"RelProd_ID"
runat
=
"server"
Width
=
"586px"
DataSourceID
=
"SqlDataSourceStock"
DataTextField
=
"Product_Title"
SelectedValue='<%# Bind("RelProd_ID") %>'
DataValueField="RelProd_ID" TabIndex="1" AppendDataBoundItems="True">
<
asp:ListItem
Selected
=
"True"
Text
=
" Select the product you wish to select as a related product "
Value
=
""
></
asp:ListItem
>
</
asp:DropDownList
>
</
td
>
</
tr
>
<
tr
><
td
colspan
=
"2"
></
td
></
tr
>
</
table
>
</
td
>
</
tr
>
<
tr
>
<
td
align
=
"right"
>
<
asp:Button
ID
=
"btnUpdate"
Text='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "Insert", "Update") %>'
runat="server" CommandName='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "PerformInsert", "Update")%>'>
</
asp:Button
>
<
asp:Button
ID
=
"btnCancel"
Text
=
"Cancel"
runat
=
"server"
CausesValidation
=
"False"
CommandName
=
"Cancel"
></
asp:Button
>
</
td
>
</
tr
>
</
table
>
</
FormTemplate
>
</
EditFormSettings
>
</
telerik:GridTableView
>
</
DetailTables
>
</
MasterTableView
>
</
telerik:RadGrid
>
But fo you filter the product by title and then delete the product, if i try a rebind on the grid it fails as the selected value of the combo in the filter template no longer exists so it errors as follows:
System.ArgumentOutOfRangeException: Selection out of range Parameter name: value
Generated: Tue, 30 Aug 2011 11:29:16 GMT
System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.ArgumentOutOfRangeException: Selection out of range
Parameter name: value
at Telerik.Web.UI.RadComboBox.PerformDataBinding(IEnumerable dataSource)
at Telerik.Web.UI.RadComboBox.OnDataSourceViewSelectCallback(IEnumerable data)
at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)
at Telerik.Web.UI.RadComboBox.OnDataBinding(EventArgs e)
at Telerik.Web.UI.RadComboBox.PerformSelect()
at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()
at System.Web.UI.Control.DataBindChildren()
at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)
at System.Web.UI.Control.DataBind()
at System.Web.UI.Control.DataBindChildren()
at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)
at System.Web.UI.Control.DataBind()
at Telerik.Web.UI.GridItem.SetupItem(Boolean dataBind, Object dataItem, GridColumn[] columns, ControlCollection rows)
at Telerik.Web.UI.GridTableView.CreateFilteringItem(Boolean useDataSource, GridColumn[] copiedColumnSet, GridTHead thead)
at Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource)
at Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource)
at System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data)
at System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data)
at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)
at System.Web.UI.WebControls.DataBoundControl.PerformSelect()
at Telerik.Web.UI.GridTableView.PerformSelect()
at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()
at Telerik.Web.UI.GridTableView.DataBind()
at Telerik.Web.UI.RadGrid.DataBind()
at connex_site_products.RadGridProducts_ItemCommand(Object source, GridCommandEventArgs e) in G:\T4\connex\site_products.aspx.vb:line 56
at Telerik.Web.UI.RadGrid.OnItemCommand(GridCommandEventArgs e)
at Telerik.Web.UI.RadGrid.OnBubbleEvent(Object source, EventArgs e)
at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
at Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e)
at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
at System.Web.UI.WebControls.ImageButton.OnCommand(CommandEventArgs e)
at System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
--- End of inner exception stack trace ---
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.connex_site_products_aspx.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Heres my code behind page:
Protected
Sub
RadGridProducts_ItemCommand(
ByVal
source
As
Object
,
ByVal
e
As
Telerik.Web.UI.GridCommandEventArgs)
Handles
RadGridProducts.ItemCommand
Select
Case
e.CommandName
Case
"DeleteProduct"
ProductItems.Delete(e.CommandArgument)
RadGridProducts.MasterTableView.DataBind()
Case
Telerik.Web.UI.RadGrid.ExportToExcelCommandName
ConfigureExport()
RadGridProducts.MasterTableView.ExportToExcel()
Case
"Edit"
Response.Redirect(
"site_editproduct.aspx?id="
& e.CommandArgument &
"&page="
& RadGridProducts.CurrentPageIndex &
"&filter="
& RadGridProducts.MasterTableView.FilterExpression.ToString)
End
Select
End
Sub
Any ideas?