I used from the training book the delete command. The problem that I am having is when I try to delete a record in the RadGrid, I get the following error:
Object referance not set to an instance of an object
The weird thing is I got it from the Telerik RadControls Ajax book and besides that I have no clue. See attached code:
| Imports System.Data.SqlClient |
| Imports Telerik.Web.UI |
| Partial Class EmployeeFamily |
| Inherits System.Web.UI.Page |
| Protected Sub RadGrid1_DeleteCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.DeleteCommand |
| Dim item As GridDataItem = DirectCast(e.Item, GridDataItem) |
| Dim MemberFamilyID As String = item.OwnerTableView.DataKeyValues(item.ItemIndex)("MemberFamilyID").ToString() |
| Try |
| 'Delete command execute |
| SqlDataSource1.DeleteCommand = "DELETE FROM MemberFamilyInfo Where MemberFamilyID = '" + MemberFamilyID + "'" |
| Catch ex As Exception |
| RadGrid1.Controls.Add(New LiteralControl("Unable to delete MemberFamily. Reason: " + ex.Message)) |
| e.Canceled = True |
| End Try |
| End Sub |
| End Class |
<
MasterTableView Width="100%" EditMode="InPlace"
<
telerik:GridDropDownColumn DropDownControlType="RadComboBox"
<telerik:RadComboBox ID="RadComboBox1" runat="server">
<Items>
<telerik:RadComboBoxItem Value="3" Text="Excellent" />
<telerik:RadComboBoxItem Value="2" Text="Good" />
<telerik:RadComboBoxItem Value="1" Text="Fair" />
<telerik:RadComboBoxItem Value="0" Text="Poor" />
<telerik:RadComboBoxItem Value="4" Text="N/A" />
</Items>
</telerik:RadComboBox>
Hi,
I have a grid pagination and I am displaying 25 items per page. If the user scrolls down and moves to the next/previous page, how can I reposition the scrollbar so the first item in the table gets visible? Should the grid do this automatically?| <div style="width:100%;height:100%"> |
| <telerik:RadGrid |
| ID="RadGrid" |
| runat="server" |
| AllowPaging="true" |
| PageSize="25" |
| Width="100%" |
| Height="100%" |
| style="border:0px;outline:none" |
| > |
| <MasterTableView TableLayout="Auto" ClientDataKeyNames="Id, Icon, IsPrivate"> |
| <Columns> |
| <telerik:GridBoundColumn DataField="Icon" HeaderText="" HtmlEncode="false" HeaderStyle-Width="26px"></telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="Name" HeaderText="Food" HtmlEncode="false" HeaderStyle-Width="100%"></telerik:GridBoundColumn> |
| </Columns> |
| </MasterTableView> |
| <ClientSettings EnableRowHoverStyle="true"> |
| <Selecting AllowRowSelect="true" /> |
| <Scrolling AllowScroll="true" UseStaticHeaders="true" /> |
| <DataBinding Location="Grid.aspx" SelectMethod="Search" FilterParameterType="String" SortParameterType="String"></DataBinding> |
| <ClientEvents OnDataBinding="RadGrid_DataBinding" OnRowClick="RadGrid_RowClick" OnRowDblClick="RadGrid_RowDblClick" OnDataBound="RadGrid_DataBound" /> |
| </ClientSettings> |
| <PagerStyle Mode="Slider" /> |
| </telerik:RadGrid> |
| </div> |
Thanks.
Hi,
I have a Repeater inside a FormView in my page.I am creating a RadComboBox control programmatically and adding it to the Repeater.
protected
void DynamicFieldsRepeater_PreRender(object sender, EventArgs e)
{
Repeater
repeater = (Repeater)sender;
RadComboBox
comboBox = new RadComboBox();
comboBox.ID =
"combo";
comboBox.DataSourceID =
"ObjectDataSource2";
comboBox.DataTextField =
"Name";
comboBox.DataValueField =
"Id";
repeater.Controls.Add(comboBox);
//DropDownList d = new DropDownList();
//d.ID = "dropdown";
//d.DataSourceID =
"ObjectDataSource2";
//d.DataTextField = "Name";
//d.DataValueField = "Id";
// repeater.Controls.Add(dropdown);
}
When I run the page I get this java script error:
'addEventListener' is null on not an object.
The thing is when I use DropDownList instead of RadComboBox,it works fine without error.
I am able to add RadDatePicker,RadTextBox,RadNumerticTextBox without the error, but not RadComboBox.
I am facing the same error when I use PlaceHolder instead of Repeater and try to add RadComboBox to to the placeholder programmatically.
Just to mention that I tried adding the controls in IntemCreated event of the repeater and the same error happend.
Thanks for your help.
Sima