or
I follow several samples and nothing seems wrong with my code, but I still receiving a NULL value error when I try to insert a value. The product_id parameter is not binded and pass onto the INSERT SQL statement. Here is my code
ASP.NET
<telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" DataSourceID="SqlDataSource1" OnItemDataBound="RadGrid1_ItemDataBound" EnableLinqExpressions ="false"> <MasterTableView AutoGenerateColumns="False" DataSourceID="SqlDataSource1" CommandItemDisplay="Top" DataKeyNames="product_name"> <EditFormSettings EditFormType="Template"> <FormTemplate> <telerik:RadAutoCompleteBox ID="radAutoCompleteBox1" runat="server" DataSourceID="SqlDataSource6" DataTextField="product_name" DataValueField="product_id" InputType="Text" Delimiter=" " SelectionMode="Single" Width="300" EmptyMessage="Type product name..."> </telerik:RadAutoCompleteBox> </FormTemplate> </EditFormSettings> </MasterTableView> </telerik:RadGrid>VB
Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs) If e.Item.IsInEditMode Then Dim item As GridEditableItem = DirectCast(e.Item, GridEditableItem) If Not (TypeOf e.Item Is IGridInsertItem) Then Dim radAutoCompleteBox1 As RadAutoCompleteBox = DirectCast(item.FindControl("radAutoCompleteBox1"), RadAutoCompleteBox) radAutoCompleteBox1.Entries.Add(New AutoCompleteBoxEntry(item("product_name").Text, item("product_name").Text)) End If End If End Sub
<telerik:RadScheduler ID="schAbsences" runat="server" HoursPanelTimeFormat="HH:mm" SelectedView="TimelineView" ShowViewTabs="false" ShowResourceHeaders="true" TimelineView-EnableExactTimeRendering="true" TimelineView-ShowDateHeaders="true" OnAppointmentDataBound ="schAbsences_AppointmentDataBound" OnAppointmentDelete="schAbsences_AppointmentDelete" OnAppointmentUpdate="schAbsences_AppointmentUpdate" ColumnHeaderDateFormat="h:mm" FirstDayOfWeek="Monday" LastDayOfWeek="Sunday" ShowAllDayRow="true" ShowFooter="true" OverflowBehavior="Expand" OnNavigationComplete="schAbsences_NavigationComplete"> <TimelineView NumberOfSlots="24" SlotDuration="01:00:00" TimeLabelSpan="1" ColumnHeaderDateFormat="HH:mm tt" /> </telerik:RadScheduler>ResourceType rt = new ResourceType(); rt.Name = "Resources"; rt.ForeignKeyField = "ResourceId"; rt.KeyField = "Id"; rt.TextField = "FullName"; List<Entities.Resource> blapp = new List<Entities.Resource>(); blapp.AddRange(DBManager.GetExistingResources()); Entities.Resource r = new Entities.Resource(); r.firstName = "Inte"; r.lastName = "tillsatt"; r.Id = 0; blapp.Insert(0, r); rt.DataSource = blapp; schAbsences.ResourceTypes.Add(rt); DateTime startTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); schAbsences.SelectedDate = startTime; schAbsences.TimelineView.GroupBy = "Resources"; schAbsences.TimelineView.GroupingDirection = GroupingDirection.Vertical;protected void schAbsences_AppointmentUpdate(object sender, AppointmentUpdateEventArgs e) { String type = e.Appointment.Attributes["appointmentType"]; if (type.Equals("Absence")) { //Do update (use Attributes) int origRsId = int.Parse(e.Appointment.Resources[0].Key.ToString()); } else { int origResId = int.Parse(e.Appointment.Resources[0].Key.ToString()); int newResId = int.Parse(e.ModifiedAppointment.Resources[0].Key.ToString()); int appointmentId=int.Parse(e.Appointment.ID.ToString()); DBManager.UpdateMovedPlacementCompetence(appointmentId, newResId); e.Cancel = true; } List<BDEvent> list = DBManager.GetAllAbsencesAsEvents(); list.AddRange(DBManager.GetAllPlacementCompetences()); schAbsences.DataSource = list; }
<Columns> <telerik:GridBoundColumn DataField="col1" HeaderText="Col 1" UniqueName="mytxt" /> <telerik:GridDropDownColumn DataField="col2" UniqueName="mydd" DropDownControlType="RadComboBox" HeaderText="Col 2" /> </Columns>if (e.Item is GridDataItem) { GridDataItem item = (GridDataItem)e.Item; DataRowView row = (DataRowView)e.Item.DataItem; item["mydd"].Text = row["col2"].ToString(); }if (e.Item is GridEditableItem && e.Item.IsInEditMode){ GridEditableItem item = (GridEditableItem)e.Item; //Controls has one control: //RadTextBox = (RadTextBox)item["mytxt"].Controls[0]; //Controls is empty: //RadComboBox com = (RadComboBox)item["mydd"].Controls[0]; }if (e.Item is GridEditableItem && e.Item.IsInEditMode){ GridEditableItem item = (GridEditableItem)e.Item; RadComboBox com = (RadComboBox)item["mydd"].Controls[0]; com.Items.Add(new RadComboxItem("a", "a")); com.Items.Add(new RadComboxItem("b", "b")); }
