Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
222 views
I have a radgrid which is using GridTemplateColumn to enable me to manage the content the way I want.  The Grid worked when i was using GridBoundColumns but when i switch i'm getting the following error.

"exhibition with ID 4 cannot be updated. Reason: Cannot insert the value NULL into column 'exhibitionTitle', table 'trevorbollenart.dbo.exhibitions'; column does not allow nulls. UPDATE fails. The statement has been terminated."

All the controls have been filled in (including exhibitionTitle) does anyone have any ideas? I'm guessing I can mix and match GridTemplateColumn and GridBoundColumns?


Code show below.

<h2>Manage exhibitions</h2>
        <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
        </telerik:RadScriptManager>
          
        <p>Items marked with a <span class="radgrid-required">*</span> are required. </p>
        <br />
          
        <br />
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" Skin="Black" runat="server" />
       <telerik:RadGrid ID="RadGrid1" GridLines="None" runat="server" AllowAutomaticDeletes="True"
            AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowPaging="True" PageSize="10"
            AutoGenerateColumns="False" DataSourceID="SqlDataSource1" AllowSorting="True" Skin="Black" ShowStatusBar="True" >
        <PagerStyle Mode="NextPrevAndNumeric" />
        <MasterTableView DataKeyNames="exhibitionID" DataSourceID="SqlDataSource1" CommandItemDisplay="Bottom" Name="exhibitions"
        CommandItemSettings-AddNewRecordText="Add New Exhibition"  >
                <RowIndicatorColumn>
                    <HeaderStyle Width="20px" />
                </RowIndicatorColumn>
                <ExpandCollapseColumn>
                    <HeaderStyle Width="20px" />
                </ExpandCollapseColumn>
<CommandItemSettings AddNewRecordText="Add New Exhibition"></CommandItemSettings>
    <Columns>
       <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn" HeaderText="Edit">
                        <ItemStyle CssClass="MyImageButton" />
                    </telerik:GridEditCommandColumn>
          
        <telerik:GridTemplateColumn HeaderText="Exhibition Title" UniqueName="exhibitionTitle" >
            <EditItemTemplate>
                <asp:TextBox ID="txtExhibitionTitle" runat="server" Width="300" MaxLength="500" Text='<%#Eval("exhibitionTitle")%>' /> <span class="radgrid-required">*</span>
                <asp:RequiredFieldValidator ID="rfvTitle" runat="server" ErrorMessage="Please enter the exhibition title" ControlToValidate="txtExhibitionTitle" Display="Dynamic" />
            </EditItemTemplate>
            <ItemTemplate>
            <%#Eval("exhibitionTitle")%>
            </ItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridTemplateColumn HeaderText="Gallery Name">
            <EditItemTemplate>
                <asp:TextBox ID="galleryName" runat="server" Width="300" MaxLength="100" Text='<%#Eval("galleryName")%>'  /> <span class="radgrid-required">*</span>
                <asp:RequiredFieldValidator ID="rfvGalleryName" runat="server" ErrorMessage="Please enter the gallery name" ControlToValidate="galleryName" Display="Dynamic" />
            </EditItemTemplate>
            <ItemTemplate>
            <%#Eval("galleryName")%>
            </ItemTemplate>
        </telerik:GridTemplateColumn>
         
         <Telerik:GridDateTimeColumn DataField="eventDateTime"
            HeaderText="Event Date & Time" SortExpression="eventDateTime"
            UniqueName="eventDateTime" PickerType="DateTimePicker"  >
        </Telerik:GridDateTimeColumn>
        <telerik:GridTemplateColumn UniqueName="TemplateColumn" HeaderText="Gallery Address">
            <ItemTemplate>
            <%#Eval("galleryAddress")%>
            </ItemTemplate>
            <EditItemTemplate>
                <asp:TextBox ID="galleryAddress" runat="server" TextMode="MultiLine" Height="100" Width="300" MaxLength="500" Text='<%#Eval("galleryAddress")%>'  /> <span class="radgrid-required">*</span>
                <asp:RequiredFieldValidator ID="rfvGalleryAddress" runat="server" ErrorMessage="Please enter the gallery address" ControlToValidate="galleryAddress" Display="Dynamic" />
            </EditItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridTemplateColumn HeaderText="Gallery Website">
            <ItemTemplate>
            <%#Eval("galleryUrl")%>
            </ItemTemplate>
            <EditItemTemplate>
                http://<;;asp:TextBox ID="galleryUrl" runat="server" Width="300" MaxLength="100" /> i.e. www.trevorbollen.co.uk
            </EditItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridBoundColumn DataField="galleryTel" HeaderText="Gallery Tel No"
            SortExpression="galleryTel" UniqueName="galleryTel">
        </telerik:GridBoundColumn>
        <telerik:GridTemplateColumn HeaderText="Notes">
            <ItemTemplate>
            <%#Eval("notes")%>
            </ItemTemplate>
            <EditItemTemplate>
               <asp:TextBox ID="notes" runat="server" TextMode="MultiLine" Width="300" MaxLength="500" />
            </EditItemTemplate>
        </telerik:GridTemplateColumn>
       <telerik:GridButtonColumn ConfirmText="Delete this exhibition?" ConfirmDialogType="RadWindow"
                        ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                        UniqueName="DeleteColumn">
                        <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                    </telerik:GridButtonColumn>
          
    </Columns>
  
<EditFormSettings>
  
<EditColumn  ButtonType="ImageButton" CancelImageUrl="~/images/btn-cancel.jpg" UpdateImageUrl="~/images/btn-update.jpg" InsertImageUrl="~/images/btn-insert.jpg"  />
</EditFormSettings>
  
</MasterTableView>
            <HeaderStyle Font-Bold="False" Font-Italic="False" Font-Overline="False"
                Font-Strikeout="False" Font-Underline="False" ForeColor="White" Wrap="True" />
        </telerik:RadGrid>
        <br />
        
      
        <br />
        <asp:SqlDataSource ID="SqlDataSource1" runat="server"
            ConnectionString="<%$ ConnectionStrings:trevorbollenartConn %>"
            InsertCommand="AddNewExhibition" InsertCommandType="StoredProcedure"
            SelectCommand="GetAllExhibitions" SelectCommandType="StoredProcedure"
            UpdateCommand="UpdateExhibition" UpdateCommandType="StoredProcedure"
            DeleteCommand="DeleteExhibition" DeleteCommandType="StoredProcedure">
            <DeleteParameters>
                <asp:Parameter Name="exhibitionID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="exhibitionID" Type="Int32" />
                <asp:Parameter Name="exhibitionTitle" Type="String" />
                <asp:Parameter Name="galleryName" Type="String" />
                <asp:Parameter Name="eventDateTime" Type="DateTime" />
                <asp:Parameter Name="galleryAddress" Type="String" />
                <asp:Parameter Name="galleryURL" Type="String" />
                <asp:Parameter Name="galleryTel" Type="String" />
                <asp:Parameter Name="Notes" Type="String" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="exhibitionTitle" Type="String" />
                <asp:Parameter Name="galleryName" Type="String" />
                <asp:Parameter Name="eventDateTime" Type="DateTime" />
                <asp:Parameter Name="galleryAddress" Type="String" />
                <asp:Parameter Name="galleryURL" Type="String" />
                <asp:Parameter Name="galleryTel" Type="String" />
                <asp:Parameter Name="Notes" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>
      
    </div>
  
</asp:Content>
stevied
Top achievements
Rank 2
 answered on 31 Mar 2011
1 answer
137 views

This is Carlos Mendoza from Accenture, US.

I’m not sure if this is also the same email address for requesting technical assistance so I’d appreciate it if you just forward to the correct group if so.

Our project purchased Telerik’s HTML editor product, and implemented it on our corporate web site, www.accenture.com

That web site is built on MOSS 2007. We have another web site, microsite.accenture.com, built in MOSS 2007 too, in which Telerik’s HTML editor is implemented in there too.

On the Microsite web site, Telerik’s toolbar is able to retrieve the site’s alternate CSS file (.css), and display the CSS classes defined inside the CSS file on the Style dropdown of Telerik’s toolbar, so they can be used by our end users. See attached screenshot below.

 

 

 

 

 

 

 

 

On the www.accenture.com web site, this is not happening on Telerik’s Style dropdown section.

Our clients would like the same behavior of the Style dropdown as the Microsites web site. Is there any configuration or line of code we should implement on the www.accenture.com platform so additional CSS classes defined on the site’s alternate CSS would appear on the Style dropdown of Telerik’s HTML editor toolbar?

 

Please advise.

 

I’d be glad to hop into a call if needed. Just tell me the telephone number of your technical support team.

 

Looking forward to hearing from you!

Stanimir
Telerik team
 answered on 31 Mar 2011
9 answers
115 views
Hello,

I am using the Popup Edit Forms with my RadGrid.  When I set the MasterTableView.EditFormSettings.CaptionFormatString to some string, the Popup window appears with two titles that say the same thing: the title of the window, and a form title below the window's title.  Both captions say the same thing...

I would like to remove the form title but leave the Popup window title... Is that possible??

Thanx,
Manuel
Pavel
Telerik team
 answered on 31 Mar 2011
1 answer
694 views
Hello,

I've implemented a requiredfieldvalidator for a radcombobox which works fine on submitting the form, however I would like to show the red asterisk before the page is submitted to indicate to the user that the field is required.  Using

Page.Validate();

in the Page_load event on the server activates the required field validators that are defined against text boxes, but I can't get the validator associated  with the combobox to show.

 
      <table>
        <tr>
            <td><telerik:RadComboBox id="ddlCostCategory" DataTextField="Name" DataValueField="ID" runat="server" SkinID="WideDll"  ></telerik:RadComboBox></td>
            <td><asp:RequiredFieldValidator runat="server" ControlToValidate ="ddlCostCategory" ID="reqValCostCategory" Text="*" ErrorMessage="Cost Category is required" InitialValue="[Select...]" ></asp:RequiredFieldValidator></td>
        </tr>
      </table>

The combobox si bound to a list with the first item having the text of [Select...] before the Page.Validate is called:

var query2 = from c in PNGC_SmartGridContext.CostCategories select c;
               IList<CostCategory> _costCategories = query2.ToList<CostCategory>();
               _costCategories.Insert(0, new CostCategory() { ID = 0, Name = "[Select...]" });
               ddlCostCategory.DataSource = _costCategories;
               ddlCostCategory.DataBind();

Note that the actual validation on submit works fine, it's just the ability to pre-trigger the red asterisk that would be great.

Thanks

Jonathan
Peter
Telerik team
 answered on 31 Mar 2011
1 answer
87 views
When I click "Add a new record", the Loading... icon at the bottom of the grid spins continuously, but the Edit works fine.

Actually, I found the problem, but I'm not sure how to fix it.

The EditFormType is Template. In the template I have the following:
<td>
    <asp:RadioButtonList ID="CommentLevel_RadioButtonList" runat="server"
                 DataSourceID="CommentLevel_SqlDataSource" DataTextField="CodeValue"
                 DataValueField="CodeName" RepeatDirection="Horizontal"
        
SelectedValue='<%# Eval("CommentCategory") %>'>
    </asp:RadioButtonList>
</td>

The problem is with the SelectedValue. When editing an existing record, there is a value in CommentCategory; but when inserting it is null.

What is the best way for me to conditionally include the SelectedValue property? On a new record, I want don't want a default value -- the user needs to think about which it should be. (An error message displays before saving if null.)
Jayesh Goyani
Top achievements
Rank 2
 answered on 31 Mar 2011
3 answers
157 views
I've got a TreeView in a combo box that works fine. What I'd like to do is keep track of which nodes are expanded in the treeview between pages (I use the control on multiple pages) I've seen code to do a treeview in a combobox and saving a treeview to a session variable but can't seem to get the combination of the two to work correctlty.

Anybody have any suggestions?

TIA - Jeff.
Shinu
Top achievements
Rank 2
 answered on 31 Mar 2011
2 answers
177 views
Is there a way to disable the Chart Title and Chart Legend to NOT be clickable when assigning the Chart a Click event? 

Putting a click event on the item, does not seem to work from code behind.
- item.ActiveRegion.Click += new RegionClickEventHandler(BaseItem_Click);
Item is clickable, but method never gets fired.

I'm using Telerik RadControls for ASP.NET Ajax - version 2010.3.1221.40

Help with any (or both) of the issues above would be greatly appreciated!


Thanks,
Katie

Katie Arnott
Top achievements
Rank 1
 answered on 30 Mar 2011
1 answer
299 views
I have a need to create an Excel Workbook with multiple worksheets and many of those worksheets will have multiple different tables inside of them.

I've learned how to create multiple worksheets but can't seem to figure out how to add multiple tables.  In the below code, you'll see I'm doing that by appending two stringbuilders together.  If I try to append the 2nd set of records ("DashboardFees") to anything other than a TableElement, I can't get it to run without an error.  Any assistance would be appreciated.  Here is what I have.

protected void rgDashboardProduction_GridExporting(object source, GridExportingArgs e)
        {
            IEnumerable<Record> productionRecords = GetDashboardProduction();
            IEnumerable<Record> feeRecords = GetDashboardFees();
 
            StringBuilder sb = new StringBuilder();
            WorksheetElement workSheet = new WorksheetElement("DashboardProduction"); //create new worksheet
            workSheet.Table = ParseRecord(productionRecords);
            
            workSheet.Render(sb); //generate xmlss code
            
            StringBuilder sb2 = new StringBuilder();
            WorksheetElement workSheet2 = new WorksheetElement("DashboardFees"); //create new worksheet
            workSheet2.Table = ParseRecord(feeRecords);
            workSheet2.Render(sb2); //generate xmlss code
 
            string output = string.Concat(sb.ToString(), sb2.ToString());
            e.ExportOutput = e.ExportOutput.Replace("</Styles>""</Styles>" + output); //add the rendered worksheet to the output
        }



private TableElement ParseRecord(IEnumerable<Record> records)
        {
            TableElement table = new TableElement();
            RowElement headerRow;
            RowElement row;
            CellElement cell;
            ColumnElement column;
 
            PropertyInfo[] properties = records.First().Properties;
            int numColumns = properties.Length;
 
            for (int col = 1; col <= numColumns; col++)
            {
                column = new ColumnElement();
                column.Attributes.Add("ss:Width", (100 * col).ToString());
                table.Columns.Add(column);
            }
 
            //Add Header Row
            headerRow = new RowElement();
            foreach (PropertyInfo property in properties)
            {
                cell = new CellElement();
                cell.StyleValue = "headerStyle";
                cell.Data.DataItem = property.Name;
                headerRow.Cells.Add(cell);
            }
 
            //Add Data Rows
            foreach (Record record in records)
            {
                row = new RowElement();
                foreach (PropertyInfo property in record.Properties)
                {
                    cell = new CellElement();
                    cell.Data.DataItem = property.GetValue(record, null);
                    row.Cells.Add(cell);
                }
                table.Rows.Add(row);
            }
 
            return table;
        }


Daniel
Telerik team
 answered on 30 Mar 2011
4 answers
200 views
Hello,

Found an article on drag & drop to multiple destinations here. In my case, it's the opposite -- I need to drag & drop (D&D) from any of four listboxes to a fifth destination listbox.

I noticed that after a first D&D from any of the source listboxes, subsequent D&D operations work only from that initial listbox, but not from any of the other three listboxes -- I assume some reference is not cleared after the first operation.

Can D&D from multiple sources be done "out-of-the-box", or does it need special handling similar to the multiple destination case?

Thanks.
SorinC
Top achievements
Rank 1
 answered on 30 Mar 2011
1 answer
66 views
Hi Admin,

I am getting problem in setting up the names in the radfilter option it shows me the Datafield values by default instead i want to use the Header Text as the Filter options , for Example i had a datafield name 'Customername' now instead of this i only want to show My HeaderText which is 'Customer' in the option. is it possible to do so.


Please reply asap.

Thanks,
Don Tompkins
Top achievements
Rank 1
 answered on 30 Mar 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?