Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
386 views
I'm getting the following error when trying to use a radcombobox inside GridTemplateColumn with inplace editing (i.e. using bind to SelectedValue).

Error:
Cannot insert the value NULL into column 'GroupTitle', table 'cms_XXXXX.dbo.cmsContentRelatedGroup'; column does not allow nulls. INSERT fails.

Why would the control pass a null value when the user enters a new "custom text" item?  Any help would be most appreciated.


Below is my RadGrid:

<telerik:RadGrid ID="rgContentRelatedGroup" runat="server" GridLines="None"
                        AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True"
                        AutoGenerateColumns="False" DataSourceID="odsContentRelatedGroup" ShowStatusBar="True">
                        <MasterTableView EditMode="InPlace" DataKeyNames="ContentRelatedGroupID"
                            CellPadding="4" CellSpacing="1" CommandItemDisplay="TopAndBottom">
                            <AlternatingItemStyle CssClass="row-alt" />
                            <ItemStyle CssClass="row" />
                            <CommandItemSettings AddNewRecordImageUrl="~/images/admin/icons/add.gif" AddNewRecordText="Add new quick link category" />
                             <Columns>
                                <telerik:GridBoundColumn DataField="ContentRelatedGroupID" DataType="System.Int32" HeaderText="ContentRelatedGroupID"
                                    ReadOnly="True" Visible="False" SortExpression="ContentRelatedGroupID" UniqueName="ContentRelatedGroupID">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="ContentID" DataType="System.Int32" HeaderText="ContentID"
                                    ReadOnly="True" Visible="False" SortExpression="ContentID" UniqueName="ContentID">
                                </telerik:GridBoundColumn>
                                <telerik:GridEditCommandColumn ButtonType="ImageButton" 
                                        UpdateImageUrl="~/images/admin/icons/update.gif"
                                        EditImageUrl="~/images/admin/icons/edit.gif" 
                                        InsertImageUrl="~/images/admin/icons/add.gif"
                                        CancelImageUrl="~/images/admin/icons/cancel.gif" HeaderText="Action">
                                    <HeaderStyle Width="55px" />
                                    <ItemStyle VerticalAlign="Top" />
                                </telerik:GridEditCommandColumn>
                                <telerik:GridTemplateColumn HeaderText="Category Title" UniqueName="columnRelatedGroup" ItemStyle-VerticalAlign="Top">
                                    <ItemTemplate>
                                        <%# Eval("GroupTitle")%>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <telerik:RadComboBox
                                             ID="rcbGroupTitle" runat="server"
                                             Width="165px" Height="200px"
                                             EmptyMessage="Select a Category"
                                             DataSourceID="odsAllContentRelatedGroup" DataTextField="GroupTitle" DataValueField="GroupTitle"
                                             AllowCustomText="true" MarkFirstMatch="true" SelectedValue='<%# Bind("GroupTitle") %>' AppendDataBoundItems="true">
                                        </telerik:RadComboBox>
                                        <asp:RequiredFieldValidator runat="server" id="reqGroupTitle" ControlToValidate="rcbGroupTitle" ErrorMessage="Category Title" display="Dynamic"><br />Category Title is a required field</asp:RequiredFieldValidator>                        
                                    </EditItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn HeaderText="Sort Order" UniqueName="columnSortOrder" ItemStyle-VerticalAlign="Top">
                                    <ItemTemplate>
                                        <%# Eval("Rank")%>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <asp:TextBox ID="tbGroupSortOrder" runat="server" Width="50" Text='<%# Bind("Rank") %>'></asp:TextBox>
                                        <asp:CompareValidator ID="cvGroupSortOrder" runat="server" Operator="DataTypeCheck" Type="Integer" ControlToValidate="tbGroupSortOrder" ErrorMessage="Sort Order" Display="Dynamic"><br />Sort Order must be a number</asp:CompareValidator>
                                        <asp:RequiredFieldValidator runat="server" id="reqGroupSortOrder" ControlToValidate="tbGroupSortOrder" ErrorMessage="Sort Order" display="Dynamic"><br />Sort Order is a required field</asp:RequiredFieldValidator>
                                    </EditItemTemplate>
                                </telerik:GridTemplateColumn>                          
                                <telerik:GridTemplateColumn HeaderText="Last Updated" UniqueName="columnLastUpdated" ItemStyle-VerticalAlign="Top">
                                    <ItemTemplate>
                                        <%# Eval("DateUpdated")%>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                    </EditItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn HeaderText="Updated By" UniqueName="columnUpdatedBy" ItemStyle-VerticalAlign="Top">
                                    <ItemTemplate>
                                        <%# Eval("UpdatedBy")%>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                    </EditItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridButtonColumn ConfirmText="Delete this category and all links associated with it?" HeaderText="Delete" ButtonType="ImageButton" ImageUrl="~/images/admin/icons/delete.gif" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn" ItemStyle-VerticalAlign="Top">
                                    <HeaderStyle Width="20px" />
                                    <ItemStyle HorizontalAlign="Center" />
                                </telerik:GridButtonColumn>      
                            </Columns>
                            <EditFormSettings ColumnNumber="2">
                                <FormTableItemStyle Wrap="False"></FormTableItemStyle>
                                <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle>
                                <FormMainTableStyle GridLines="Horizontal" CellSpacing="0" CellPadding="3" BackColor="White"
                                    Width="100%" />
                                <FormTableStyle CellSpacing="0" CellPadding="2" CssClass="module" Height="110px"
                                    BackColor="White" />
                                <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
                                <EditColumn ButtonType="ImageButton" UpdateImageUrl="~/images/admin/icons/update.gif"
                                    EditImageUrl="~/images/admin/icons/edit.gif" InsertImageUrl="~/images/admin/icons/add.gif"
                                    CancelImageUrl="~/images/admin/icons/cancel.gif" InsertText="Insert record" UpdateText="Update record"
                                    UniqueName="ContentGroupEditCommandColumn" CancelText="Cancel edit">
                                </EditColumn>
                                <FormTableButtonRowStyle HorizontalAlign="Right"></FormTableButtonRowStyle>
                            </EditFormSettings>
                            <ExpandCollapseColumn Visible="False">
                                <HeaderStyle Width="19px" />
                            </ExpandCollapseColumn>
                            <RowIndicatorColumn Visible="False">
                                <HeaderStyle Width="20px" />
                            </RowIndicatorColumn>
                        </MasterTableView>
                    </telerik:RadGrid>

And here are the two datasources:

<asp:ObjectDataSource ID="odsAllContentRelatedGroup" runat="server" SelectMethod="GetAllContentRelatedGroup" 
                        TypeName="dsCmsContentTableAdapters.cmsContentRelatedGroupTableAdapter">
                    </asp:ObjectDataSource>
                    
                    <asp:ObjectDataSource ID="odsContentRelatedGroup" runat="server" DeleteMethod="DeleteContentRelatedGroup"
                        InsertMethod="InsertContentRelatedGroup" SelectMethod="GetContentRelatedGroupByContentID" TypeName="dsCmsContentTableAdapters.cmsContentRelatedGroupTableAdapter"
                        UpdateMethod="UpdateContentRelatedGroup">
                        <SelectParameters>
                            <asp:SessionParameter Name="ContentID" SessionField="ContentID" Type="Int32" />
                        </SelectParameters>
                        <InsertParameters>
                            <asp:SessionParameter Name="ContentID" SessionField="ContentID" Type="Int32" />
                            <asp:Parameter Name="GroupTitle" Type="String" />
                            <asp:Parameter Name="Rank" Type="Int32" />
                            <asp:SessionParameter Name="CreatedBy" SessionField="Username" Type="String" />
                            <asp:Parameter Direction="InputOutput" Name="NewContentRelatedGroupID" Type="Object" />
                        </InsertParameters>
                        <DeleteParameters>
                            <asp:Parameter Name="ContentRelatedGroupID" Type="Int32" />
                        </DeleteParameters>
                    </asp:ObjectDataSource>

And finally the stack:

System.Reflection.TargetInvocationException was unhandled by user code
  Message=Exception has been thrown by the target of an invocation.
  Source=mscorlib
  StackTrace:
       at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
       at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at System.Web.UI.WebControls.ObjectDataSourceView.InvokeMethod(ObjectDataSourceMethod method, Boolean disposeInstance, Object& instance)
       at System.Web.UI.WebControls.ObjectDataSourceView.ExecuteInsert(IDictionary values)
       at System.Web.UI.DataSourceView.Insert(IDictionary values, DataSourceViewOperationCallback callback)
       at Telerik.Web.UI.GridTableView.PerformInsert(GridEditableItem editedItem, Boolean suppressRebind)
       at Telerik.Web.UI.GridTableView.PerformInsert(GridEditableItem editedItem)
       at Telerik.Web.UI.GridTableView.PerformInsert()
       at Telerik.Web.UI.GridCommandEventArgs.ExecuteCommand(Object source)
       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 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 admin_content_edit.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) in e:\work\wwwroot\cms.wageworks\admin\content-edit.aspx.cs:line 359
       at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  InnerException: System.Data.SqlClient.SqlException
       Message=Cannot insert the value NULL into column 'GroupTitle', table 'cms_XXXXXX.dbo.cmsContentRelatedGroup'; column does not allow nulls. INSERT fails.
The statement has been terminated.
       Source=.Net SqlClient Data Provider
       ErrorCode=-2146232060
       Class=16
       LineNumber=17
       Number=515
       Procedure=usp_cmsContentRelatedGroupINSERT
       Server=XXXXXXXXXX
       State=2
       StackTrace:
            at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
            at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
            at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
            at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
            at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
            at System.Data.SqlClient.SqlDataReader.get_MetaData()
            at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
            at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
            at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
            at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
            at System.Data.SqlClient.SqlCommand.ExecuteScalar()
            at dsCmsContentTableAdapters.cmsContentRelatedGroupTableAdapter.InsertContentRelatedGroup(Nullable`1 ContentID, String GroupTitle, Nullable`1 Rank, String CreatedBy, Nullable`1& NewContentRelatedGroupID) in c:\Users\mrhigh\AppData\Local\Temp\Temporary ASP.NET Files\root\98f11740\866a4947\App_Code.6d7gpkps.5.cs:line 16649
       InnerException: 

Shinu
Top achievements
Rank 2
 answered on 16 Oct 2012
3 answers
99 views
I want to loop through a hierarchy radgrid to find a  specific value within the 2nd level of the rad grid's hierarchy.  I do not want the value of the key, but the values of other columns within the 2nd level of the hierarchy.  How can I loop through the items to obtain these values.  This is what I have so far, but it does not work....

   Protected Sub RadGrid_Inventory_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid_Inventory.PreRender


            For Each item As GridDataItem In RadGrid_Inventory.Items
                If (item.OwnerTableView.Name = "Inv_Desc") Then


                Dim lblRowID As Label = DirectCast(item.FindControl("lblRowID"), Label)
                Dim Delete As ImageButton = DirectCast(item.FindControl("Delete"), ImageButton)
            

                If lblRowID.Text = -1 Then
                    Delete.Visible = False
                Else
                    Delete.Visible = True
                End If


                End If
            Next
    End Sub
Aret
Top achievements
Rank 1
 answered on 16 Oct 2012
2 answers
106 views

Hi,

My team is having an issue with the NumericTextBox and the developer currently having the issue asked that I post his question in the forum on his behalf since he is having a technical issue with his workstation that is preventing him from posting himself.

"Using the NumericTextbox, I am seeing behavior that is not the way that I want or expect. I have a MinValue="0" and a MaxValue="100". I have a InvalidStyleDuration="2000000".

When the user enters -1, the textbox border turns red and there is an invalid icon in the textbox. What is happening that I don't want is that the -1 value that was entered is replaced by the MinValue, 0. How can I get the entered value, -1, to remain in the textbox?"

Thanks,

Andrew

Andrew
Top achievements
Rank 1
 answered on 15 Oct 2012
2 answers
229 views
Hi,

My team is having an issue with the NumericTextBox and the developer currently having the issue asked that I post his question in the forum on his behalf since he is having a technical issue with his workstation that is preventing him from posting himself.

"I have a NumericTextBox that has MinValue and MaxValue properties.I have a ValidationSummary control which has a RequiredFieldValidator connected to another asp.net TextBox control.

When the user hits the Save button and validation takes place, is there a way for invalid values in the NumericTextBox control, for example value entered is less than the MinValue, to be displayed in the ValidationSummary control without hooking up an additional asp.net validation control?"

Thanks,

Andrew

Andrew
Top achievements
Rank 1
 answered on 15 Oct 2012
1 answer
104 views
Hello,

I've been looking around the Telerik and the internet for the last few days to fry and find a possible solution for designing a grid that allows manual entry.  To be specific, here's exactly what I am looking for -

  1. User clicks Add New Record to enter new data
  2. Mouse cursor automatically starts in the first data field; as the user tabs across, the cursor continues to move from column to column, allowing the user to enter all values
  3. The input of each field can be customized - in other words, some of the entry fields would simply be text entry, some would be dropdown menus (RadCombo) and some are date fields (RadDatePicker)
  4. When the user tabs from the last column, the record is automatically validated and/or inserted into the grid.  The cursor then returns to the first column to allow entry of the next record

I have been experimenting both with the User Control and Template Edit Form Type (currently I am working with the Template).  There have been a few issues based on how I'm coding it:

  1. Despite setting the tab index of the items in the template, tabbing through them is giving a random tab order and not following the set tab index settings
  2. I am curently working with the last field in the template set with Auto Postback - this was my initial plan for simulating the automatic insertion, although I was doubtful this would work (and so far it hasn't).

Is there a sample somewhere on the Telerik site that follows a similar approach?  I haven't been able to find anything that mimics this behavior, but perhaps I am searching for the wrong thing or describing it wrong.

amonte
Top achievements
Rank 1
 answered on 15 Oct 2012
6 answers
365 views
Hi,
I have many columns in my radgrid, and thus I have horizontle scrolling enabled. But, I would like to allow the user to select the columns they want to have displayed by having option on the header of a column as shown in the below link:
http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/headercontextfiltermenu/defaultcs.aspx

Eveything is good, but my radgrid columns are created programatically. It would be great if someone can guide me in doing this programatically in code behind file.

Thanks,
Raj
David Cowan
Top achievements
Rank 1
 answered on 15 Oct 2012
2 answers
156 views


In the above example, even though the second file Lighthouse.jpg fails validation, it in the file list. Although the green and red bullet show the status of each file, it is not as intuitive, especially if you select multiple at a time. Firstly you have to scan through the list to see which all failed. Secondly colourblind people can have a hard time distinguishing them.

How can I make it so that files that fail validation don't show up there? I'm planning to have a error area below the upload control that will list files that fail validation and only show validated files up there.

Thanks.
Baal
Top achievements
Rank 1
 answered on 15 Oct 2012
0 answers
58 views
Delete
Bruce
Top achievements
Rank 1
 asked on 15 Oct 2012
0 answers
181 views
I have a radlistbox that contains enough items to cause the vertical scroll bar to appear. My page allows a new record to be inserted into the database and on postback I rebind the records to the listbox and set the radlistbox selected item to the new record's text which is near the bottom of the listbox; however, the scroll bar remains at the top of the radlistbox. How can I move the vertical scroll bar to make visible the newly inserted and selected item?

Thanks,

Steve Holdorf
Steve Holdorf
Top achievements
Rank 1
 asked on 15 Oct 2012
2 answers
2.1K+ views
Having trouble getting a radgrid column to format as $1,234.00; it always displays as 1234.  The database field is Double. The code is as follows:
       <telerik:RadGrid ID="RadGrid1" runat="server" style="margin-top:25px;"
AutoGenerateColumns="true" oncolumncreated="RadGrid1_ColumnCreated">
           <MasterTableView  TableLayout="Fixed" />
           <ClientSettings EnableRowHoverStyle="true" >
               <Selecting AllowRowSelect="False"/>
               <ClientEvents />
               <Scrolling AllowScroll="True"/>
               <Resizing AllowColumnResize="true" AllowResizeToFit="true" ResizeGridOnColumnResize="true" />
           </ClientSettings>
       </telerik:RadGrid>

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using System.Data;
using myNameSpace.BusinessLogic.myLogic;
 
namespace myNameSpace
{
    public partial class myScreen : System.Web.UI.UserControl
    {
        private MyController myController = new MyController();
        protected void Page_Load(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            List<Guid> thisPositionIds = myController.GetPositionIDs();
            // add 1st column, the Item
            dt.Columns.Add("Item");
 
            // make the Annual Costs columns
            foreach (Guid positionId in thisPositionIds)
            {
                // add a column
                dt.Columns.Add(new DataColumn(myController.GetPositionName(positionId)
                    + System.Environment.NewLine + "Annual Costs",
                    System.Type.GetType("System.Decimal")));
            }
 
            // get the data for the rows
            List<Guid> thisItemIds = myController.GetItemIDs();
            foreach (Guid itemID in thisItemIds)
            {
                DataRow dr = dt.NewRow();
 
                // enter the first column, the Item Name
                dr["Item"] = myController.GetItemName(itemID);
 
                // enter the final set of columns, the Annual Costs
                foreach (Guid positionId in thisPositionIds)
                {
                    dr[myController.GetPositionName(positionId) + System.Environment.NewLine + "Annual Costs"]
                        = myController.GetAnnualCosts(itemID, positionId);
                }
                dt.Rows.Add(dr);
            }
            RadGrid1.DataSource = dt;
            RadGrid1.DataBind();
        }
 
        protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
        {
            if (e.Column.ColumnType == "GridBoundColumn")
            {
                // get column header text
                string colName = e.Column.UniqueName;
 
                // get last 12 chars of text (if it is long enough)
                string colNameEnd;
                if (colName.Length >= 12)
                    colNameEnd = colName.Substring(colName.Length - 12, 12);
                else
                    colNameEnd = "x";
                // format according to which column this
                if (colName == "Item")
                    e.Column.HeaderStyle.Width = Unit.Pixel(80);
                else if (colNameEnd == "Annual Costs")
                {
                    (e.Column as GridBoundColumn).DataFormatString = "{0:C}";
                }
            }
        }
    }
}

Any hints as to what I'm missing would be appreciated.
-Scott
Scott
Top achievements
Rank 1
 answered on 15 Oct 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?