I'm trying to get a RadComboBox to work in RadGrid FormTemplate.I'm getting this error:
Line: 15
Error: Sys.WebForms.PageRequestManagerServerErrorException: Selection out of range
Parameter name: value
.aspx
.cs
Line: 15
Error: Sys.WebForms.PageRequestManagerServerErrorException: Selection out of range
Parameter name: value
.aspx
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AllowFilteringByColumn
=
"True"
AllowPaging
=
"True"
AllowSorting
=
"True"
AutoGenerateColumns
=
"False"
DataSourceID
=
"SqlDataSource1"
OnItemDeleted
=
"RadGrid1_ItemDeleted"
OnItemInserted
=
"RadGrid1_ItemInserted"
OnItemUpdated
=
"RadGrid1_ItemUpdated"
GridLines
=
"None"
AllowAutomaticDeletes
=
"True"
AllowAutomaticInserts
=
"True"
AllowAutomaticUpdates
=
"True"
>
<
GroupingSettings
CaseSensitive
=
"False"
></
GroupingSettings
>
<
ClientSettings
AllowColumnsReorder
=
"True"
>
<
Selecting
AllowRowSelect
=
"True"
/>
<
Selecting
AllowRowSelect
=
"True"
></
Selecting
>
</
ClientSettings
>
<
GroupingSettings
CaseSensitive
=
"false"
/>
<
MasterTableView
autogeneratecolumns
=
"False"
DataKeyNames
=
"id"
DataSourceID
=
"SqlDataSource1"
>
<
Columns
>
<
telerik:GridEditCommandColumn
ButtonType
=
"PushButton"
>
</
telerik:GridEditCommandColumn
>
<
telerik:GridBoundColumn
DataField
=
"s_page"
DefaultInsertValue
=
""
HeaderText
=
"s_page"
UniqueName
=
"s_page"
SortExpression
=
"s_page"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"s_doc_title"
DefaultInsertValue
=
""
HeaderText
=
"s_doc_title"
UniqueName
=
"s_doc_title"
SortExpression
=
"s_doc_title"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"s_doc_url"
DefaultInsertValue
=
""
HeaderText
=
"s_doc_url"
SortExpression
=
"s_doc_url"
UniqueName
=
"s_doc_url"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"d_date_uploaded"
DataType
=
"System.DateTime"
DefaultInsertValue
=
""
HeaderText
=
"d_date_uploaded"
SortExpression
=
"d_date_uploaded"
UniqueName
=
"d_date_uploaded"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"d_date_displayed"
DataType
=
"System.DateTime"
DefaultInsertValue
=
""
HeaderText
=
"d_date_displayed"
SortExpression
=
"d_date_displayed"
UniqueName
=
"d_date_displayed"
>
</
telerik:GridBoundColumn
>
<
telerik:GridCheckBoxColumn
DataField
=
"b_visible"
DefaultInsertValue
=
""
HeaderText
=
"b_visible"
UniqueName
=
"b_visible"
DataType
=
"System.Boolean"
SortExpression
=
"b_visible"
>
</
telerik:GridCheckBoxColumn
>
</
Columns
>
<
EditFormSettings
ColumnNumber
=
"3"
CaptionFormatString
=
"Edit details for {0}"
CaptionDataField
=
"id"
EditColumn-ButtonType
=
"PushButton"
EditFormType
=
"Template"
>
<
FormTableItemStyle
Wrap
=
"False"
></
FormTableItemStyle
>
<
FormTableStyle
CellPadding
=
"2"
CellSpacing
=
"0"
GridLines
=
"Horizontal"
CssClass
=
"module"
Height
=
"110px"
Width
=
"100%"
></
FormTableStyle
>
<
FormMainTableStyle
CellPadding
=
"3"
CellSpacing
=
"0"
Width
=
"100%"
></
FormMainTableStyle
>
<
FormCaptionStyle
CssClass
=
"EditFormHeader"
></
FormCaptionStyle
>
<
FormMainTableStyle
GridLines
=
"None"
CellSpacing
=
"0"
CellPadding
=
"3"
Width
=
"100%"
/>
<
FormTableStyle
GridLines
=
"Horizontal"
CellSpacing
=
"0"
CellPadding
=
"2"
CssClass
=
"module"
Height
=
"110px"
Width
=
"100%"
/>
<
FormTableAlternatingItemStyle
Wrap
=
"False"
></
FormTableAlternatingItemStyle
>
<
FormStyle
Width
=
"100%"
BackColor
=
"#eef2ea"
></
FormStyle
>
<
EditColumn
UpdateText
=
"Update record"
UniqueName
=
"EditCommandColumn1"
CancelText
=
"Cancel edit"
ButtonType
=
"PushButton"
>
</
EditColumn
>
<
FormTableButtonRowStyle
HorizontalAlign
=
"Left"
CssClass
=
"EditFormButtonRow"
></
FormTableButtonRowStyle
>
<
FormTemplate
>
<
table
cellspacing
=
"0"
cellpadding
=
"0"
border
=
"0"
>
<
tr
>
<
td
width
=
"400"
>
<
table
cellspacing
=
"0"
cellpadding
=
"0"
border
=
"0"
>
<
tr
>
<
td
width
=
"5"
>
</
td
>
<
td
width
=
"375"
valign
=
"top"
>
ID:
</
td
>
<
td
>
<
asp:Label
ID
=
"lbl_id"
runat
=
"server"
Text='<%# Bind("id") %>'></
asp:Label
>
</
td
>
</
tr
>
<
tr
>
<
td
width
=
"5"
>
</
td
>
<
td
width
=
"375"
valign
=
"top"
>
Page:
</
td
>
<
td
>
<
telerik:RadComboBox
ID
=
"RadComboBox1"
runat
=
"server"
DataSourceID
=
"SqlDataSource3"
DataTextField
=
"MenuText"
DataValueField
=
"MenuId"
SelectedValue='<%# Bind("s_page") %>'
Skin="Vista" AutoPostBack="True">
</
telerik:RadComboBox
>
</
td
>
</
tr
>
<
tr
>
<
td
width
=
"5"
>
</
td
>
<
td
width
=
"375"
valign
=
"top"
>
Doc. Title:
</
td
>
<
td
>
<
asp:TextBox
Width
=
"240px"
ID
=
"txtbx_title"
runat
=
"server"
Text='<%# Bind("s_doc_title") %>'></
asp:TextBox
>
</
td
>
</
tr
>
<
tr
>
<
td
width
=
"5"
>
</
td
>
<
td
width
=
"375"
valign
=
"top"
>
Date Uploaded:
</
td
>
<
td
>
<
asp:TextBox
Width
=
"240px"
ID
=
"TextBox3"
runat
=
"server"
Text='<%# Bind("d_date_uploaded") %>'></
asp:TextBox
>
</
td
>
</
tr
>
<
tr
>
<
td
width
=
"5"
>
</
td
>
<
td
width
=
"375"
valign
=
"top"
>
Date Displayed:
</
td
>
<
td
>
<
asp:TextBox
Width
=
"240px"
ID
=
"TextBox4"
runat
=
"server"
Text='<%# Bind("d_date_displayed") %>'></
asp:TextBox
>
</
td
>
</
tr
>
</
table
>
</
td
>
<
td
width
=
"400"
>
<
table
>
<
tr
>
<
td
width
=
"5"
>
</
td
>
<
td
width
=
"90"
valign
=
"top"
>
PDF File Name:
</
td
>
<
td
>
<
asp:TextBox
Width
=
"240px"
ID
=
"TextBox2"
runat
=
"server"
Text='<%# Bind("s_doc_url") %>'></
asp:TextBox
>
<
asp:Button
ID
=
"btn_pdf_upload"
runat
=
"server"
Text
=
"Upload PDF File"
onclick
=
"btn_pdf_upload_Click"
/>
</
td
>
</
tr
>
</
table
>
</
td
>
</
tr
>
<
tr
>
<
td
colspan
=
"2"
align
=
"center"
>
<
asp:Button
ID
=
"btnUpdate"
Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
</
asp:Button
>
<
asp:Button
ID
=
"Button2"
runat
=
"server"
Text
=
"Cancel"
CausesValidation
=
"false"
CommandName
=
"Cancel"
></
asp:Button
>
</
td
>
</
tr
>
</
table
>
</
FormTemplate
>
</
EditFormSettings
>
<
PagerStyle
Position
=
"TopAndBottom"
/>
</
MasterTableView
>
</
telerik:RadGrid
>
<
asp:SqlDataSource
ID
=
"SqlDataSource3"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:SugarSandsConnectionString %>"
SelectCommand="SELECT [MenuId], [MenuText] FROM [tbl_menu] ORDER BY [MenuText]"></
asp:SqlDataSource
>
<
br
/>
<
asp:SqlDataSource
ID
=
"SqlDataSource1"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:SugarSandsConnectionString %>"
SelectCommand="SELECT * FROM [tbl_pdf_docs] ORDER BY [s_page]" DeleteCommand="DELETE FROM [tbl_pdf_docs] WHERE [id] = @id"
InsertCommand="INSERT INTO [tbl_pdf_docs] ([s_page], [s_doc_title], [s_link_title], [s_doc_url], [d_date_uploaded], [d_date_displayed], [b_visible]) VALUES (@s_page, @s_doc_title, @s_link_title, @s_doc_url, @d_date_uploaded, @d_date_displayed, @b_visible)"
UpdateCommand="UPDATE [tbl_pdf_docs] SET [s_page] = @s_page, [s_doc_title] = @s_doc_title, [s_doc_url] = @s_doc_url, [d_date_uploaded] = @d_date_uploaded, [d_date_displayed] = @d_date_displayed, [b_visible] = @b_visible WHERE [id] = @id">
<
DeleteParameters
>
<
asp:Parameter
Name
=
"id"
Type
=
"Int32"
/>
</
DeleteParameters
>
<
InsertParameters
>
<
asp:Parameter
Name
=
"s_page"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"s_doc_title"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"s_doc_url"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"d_date_uploaded"
Type
=
"DateTime"
/>
<
asp:Parameter
Name
=
"d_date_displayed"
Type
=
"DateTime"
/>
<
asp:Parameter
Name
=
"b_visible"
Type
=
"Boolean"
/>
</
InsertParameters
>
<
UpdateParameters
>
<
asp:Parameter
Name
=
"s_page"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"s_doc_title"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"s_doc_url"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"d_date_uploaded"
Type
=
"DateTime"
/>
<
asp:Parameter
Name
=
"d_date_displayed"
Type
=
"DateTime"
/>
<
asp:Parameter
Name
=
"b_visible"
Type
=
"Boolean"
/>
<
asp:Parameter
Name
=
"id"
Type
=
"Int32"
/>
</
UpdateParameters
>
</
asp:SqlDataSource
>
</
td
>
</
tr
>
<
telerik:RadAjaxManager
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadGrid1"
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"SqlDataSource1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadGrid1"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"SqlDataSource1"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
protected void RadGrid1_ItemUpdated(object source, Telerik.Web.UI.GridUpdatedEventArgs e)
{
if (e.Exception != null)
{
e.KeepInEditMode = true;
e.ExceptionHandled = true;
DisplayMessage(true, "Title " + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["s_doc_title"] + " cannot be updated. Reason: " + e.Exception.Message);
}
else
{
DisplayMessage(false, "Title " + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["s_doc_title"] + " updated");
}
}
protected void RadGrid1_ItemInserted(object source, GridInsertedEventArgs e)
{
if (e.Exception != null)
{
e.ExceptionHandled = true;
e.KeepInInsertMode = true;
DisplayMessage(true, "Title cannot be inserted. Reason: " + e.Exception.Message);
}
else
{
DisplayMessage(false, "Title inserted");
}
}
protected void RadGrid1_ItemDeleted(object source, GridDeletedEventArgs e)
{
if (e.Exception != null)
{
e.ExceptionHandled = true;
DisplayMessage(true, "Title " + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["s_doc_title"] + " cannot be deleted. Reason: " + e.Exception.Message);
}
else
{
DisplayMessage(false, "Title " + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["s_doc_title"] + " deleted");
}
}
private void DisplayMessage(bool isError, string text)
{
Label label = (isError) ? this.Label1 : this.Label2;
label.Text = text;
}
private static DataTable tblData = new DataTable();
protected void Page_Load(object sender, System.EventArgs e)
{
}
//protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
//{
// if (e.CommandName == "Update")
// {
// GridEditFormItem gridEditFormItem = (GridEditFormItem)e.Item;
// Label label = (Label)gridEditFormItem.FindControl("lbl_id");
// TextBox textboxPage = (TextBox)gridEditFormItem.FindControl("s_page");
// TextBox textboxDocTitle = (TextBox)gridEditFormItem.FindControl("s_doc_title");
// TextBox textboxLinkTitle = (TextBox)gridEditFormItem.FindControl("s_link_title");
// TextBox textboxDocUrl = (TextBox)gridEditFormItem.FindControl("s_doc_url");
// TextBox textboxDateUp = (TextBox)gridEditFormItem.FindControl("d_date_uploaded");
// TextBox textboxDateDisplay = (TextBox)gridEditFormItem.FindControl("d_date_displayed");
// SqlDataSource1.UpdateCommand = "UPDATE [tbl_pdf_docs] SET [s_page] = @s_page, [s_doc_title] = @s_doc_title, [s_doc_url] = @s_doc_url, [d_date_uploaded] = @d_date_uploaded, [d_date_displayed] = @d_date_displayed WHERE id= @lbl_id";
// SqlDataSource1.Update();
// }
// if (e.CommandName == RadGrid.InitInsertCommandName) //"Add new" button clicked
// {
// GridEditCommandColumn editColumn = (GridEditCommandColumn)RadGrid1.MasterTableView.GetColumn("EditCommandColumn");
// editColumn.Visible = false;
// e.Canceled = true;
// e.Item.OwnerTableView.InsertItem();
// GridEditableItem insertedItem = e.Item.OwnerTableView.GetInsertItem();
// TextBox box = insertedItem.FindControl("txt_company_id") as TextBox;
// box.Text = Request.QueryString["id"].ToString();
// }
// else if (e.CommandName == RadGrid.RebindGridCommandName && e.Item.OwnerTableView.IsItemInserted)
// {
// e.Canceled = true;
// }
// else
// {
// GridEditCommandColumn editColumn = (GridEditCommandColumn)RadGrid1.MasterTableView.GetColumn("EditCommandColumn");
// if (!editColumn.Visible)
// editColumn.Visible = true;
// }
//}
protected void btn_pdf_upload_Click(object sender, EventArgs e)
{
Response.Redirect("pdf_file_upload.aspx");
}
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
//if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
//{
// GridEditFormItem editform = (GridEditFormItem)e.Item;
// RadComboBox ddl_menu_items = (RadComboBox)editform.FindControl("RadComboBox1");
// //Populate the dropdownlist
// SqlCommand cmd = new SqlCommand("SELECT [MenuId], [MenuText] FROM [tbl_menu] ORDER BY [MenuText]", new SqlConnection(ConfigurationManager.AppSettings["SugarSandsConnectionString"]));
// cmd.Connection.Open();
// SqlDataReader ddlValues;
// ddlValues = cmd.ExecuteReader();
// ddl_menu_items.DataSource = ddlValues;
// ddl_menu_items.DataValueField = "MenuId";
// ddl_menu_items.DataTextField = "MenuText";
// ddl_menu_items.DataBind();
// cmd.Connection.Close();
// cmd.Connection.Dispose();
//}
}