Asp Dot Net Notes for Web Masters RSS 2.0

# Tuesday, February 02, 2010
Accessing the columns of a Detail Table that belongs to a RadGrid can be difficult.

I wanted to make some columns ReadOnly because they are Data Key Names or Foreign Key Names. There may be another way to achieve this behaviour but I could not find it.

Below is the solution I came up with.

/// <summary>
/// Makes the ID rows readonly. Have to use because the cols are Generated automatically
/// </summary>
/// <param name="source"></param>
/// <param name="e"></param>
protected void Websites_RadGrid_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
{
    //##DetailTableDataBind Info at:
    //http://www.telerik.com/help/aspnet-ajax/grdhierarchicaldatabindingusingdetailtabledatabind.html         

    //Get the required cols 
    var Col1 = e.DetailTableView.AutoGeneratedColumns.SingleOrDefault(ColName => ColName.IsBoundToFieldName("DomainID"));
    var Col2 = e.DetailTableView.AutoGeneratedColumns.SingleOrDefault(ColName => ColName.IsBoundToFieldName("WebSiteID"));
    //If the col exists them make it read only.
    if (Col1 != null)
    {
        (Col1 as Telerik.Web.UI.GridBoundColumn).ReadOnly = true;
    }
    if (Col2 != null)
    {
        (Col2 as Telerik.Web.UI.GridBoundColumn).ReadOnly = true;
    }
}

Tuesday, February 02, 2010 12:07:10 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] - Trackback
Controls
# Sunday, June 21, 2009
Add functions such as Indent, Outdent, Custom Styles Selector, Custom Links Selector, Font Name, Font Size, Font ForeColor, Font BackColor, ConvertToLower, ConvertToUpper  Apply Custom Class Drop Down, Superscript, Subscript, Insert Paragraph, Insert Horizontal Rule, Help, Style Builder, Xhtml Validator, TrackChangesDialog, FormatCodeBlock, TableWizard, InsertSymbol etc.

To see available tools open file: Sitefinity/Admin/ControlTemplates/EditorToolsFileAll.xml.

E.g.
  <tools name="DropdownToolbar" dockable="false">
    <tool name="ForeColor" />
    <tool name="BackColor" />
    <tool separator="true" />
    <tool name="FontName" />
    <tool name="FontSize" />
    <tool name="ApplyClass" />
    <tool name="InsertCustomLink" />
    <tool name="FormatBlock" />
    <tool name="FormatStripper" />
  </tools>

Copy the required lines to the file: Sitefinity/Admin/ControlTemplates/EditorToolsFile.xml

Now save the file and and open Rad Editor to see the extra tools.

Sunday, June 21, 2009 8:27:10 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] - Trackback
Controls
# Wednesday, June 03, 2009
When trying to add inline Java Script to a Generic Content control the script tags are HTML encoded / removed.
This is the default behaviour so we must enable script tags.

To do this you must edit the control template for Generic Content.

Open the following file in Visual Studio:
Sitefinity --> Admin --> ControlTemplates --> Generic_Content --> App_LocalResources --> ContentVersionView.aspx.resx

Add a new setting: ContentFilters = None

There are still some problems with this. E.g. If you use a noscript tag then the contents of that tag will still get HTML encoded.
Wednesday, June 03, 2009 4:25:05 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] - Trackback
Controls
# Sunday, May 31, 2009

Radgrid;  Add New Record Button not visible

The first time you use RadGrid you may spend a lot of time trying to work out how to display the Add New Record Button. I had to search for ages to find out what to do to display the Add New Record Button.

The property you need to set is the CommandItemDisplay of the MasterTableView property.

In Visual Studio you can edit the properties of the RadGrid in the property editor window. Select the RadGrid on your page, and then find the property called MasterTableView and its child property CommandItemDisplay.  Now select one of the drop down options: None, Top, Bottom , TopAndBottom.  Like magic the Add new button appears.

Remember to set AllowAutomaticInserts to true if you are not writing your own insert code.

 The MasterTableView code that may look something like this, notice the property CommantItemDisplay="Top":

<MasterTableView DataKeyNames="PriceTypeID" 
        DataSourceID="PriceType_LinqDataSource" CommandItemDisplay="Top">
<RowIndicatorColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>

<ExpandCollapseColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
    <Columns>
        <telerik:GridBoundColumn DataField="PriceType" HeaderText="PriceType" 
            SortExpression="PriceType" UniqueName="PriceType">
        </telerik:GridBoundColumn>
    </Columns>
</MasterTableView>

Sunday, May 31, 2009 2:04:38 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] - Trackback
Controls
# Sunday, May 17, 2009
To add a confirmation to the automatically generated delete button you can add an event handler to the ItemDataBund event of the grid. The code below adds a confirmation message that appears in a dialog box. The message also displays the row data to help the user know what he is deleting.
    public void PriceType_RadGrid_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            //Get the Data we want to show to the User
            GridDataItem dataItem = e.Item as GridDataItem;
            string DataItem = dataItem["PriceType"].Text;

            //Add the message to the Button
            LinkButton button = e.Item.FindControl("AutoGeneratedDeleteButton") as LinkButton;
            button.Attributes["onclick"] = "return confirm('Are you sure you want to delete " +
            DataItem + "?')";
        }
    }

Sunday, May 17, 2009 3:27:45 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] - Trackback
Controls
Archive
<February 2012>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910
Blogroll
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2012
I do I.T. Ltd.
Sign In
Statistics
Total Posts: 27
This Year: 0
This Month: 0
This Week: 0
Comments: 22
All Content © 2012, I do I.T. Ltd.