Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
98 views
Hi

View Image attached

In the ItemDataBount I do stuff to customize the GridGroupHeaderItem wich works fine.

When I click on the grid and come back to it, the formatting is lost (right side of the Image attached)

I use the RadAjaxManager and the grid is updated on the event but is not rebinded.

Is there a way not to loose this without rebinding.

here the code if it help

        protected void rdgMeals_ItemDataBound(object source, GridItemEventArgs e)
        {
            if (e.Item != null)
            {
                if (e.Item.ItemType == GridItemType.GroupHeader)
                {
                    GridGroupHeaderItem xGridGroupHeaderItem = (GridGroupHeaderItem)e.Item;
                    HtmlAnchor xHtmlAnchor = new HtmlAnchor();
                    String xDate = ((DateTime)DataBinder.Eval(xGridGroupHeaderItem.DataItem, "Date")).ToString("yyyy-MM-dd");

                    xHtmlAnchor.InnerHtml = "<img alt='Statistics' src='/Images/Statistics.png' height='12' width='12' style='border: none;' /> " + xDate;
                    xHtmlAnchor.HRef = "javascript:void(0);";
                    xHtmlAnchor.Attributes.Add("onclick", "OpenFoodStatisticsMeals('0', '" + this.CurrentUserId + "', '" + xDate + "', '" + xDate + "');");
                    xHtmlAnchor.Style.Add("color", "#000000");
                    xHtmlAnchor.Style.Add("border", "none");
                    xHtmlAnchor.Style.Add("text-decoration", "none");

                    xGridGroupHeaderItem.DataCell.Controls.Add(xHtmlAnchor);
                }
     }
 }



Thanks
Iana Tsolova
Telerik team
 answered on 17 Oct 2011
1 answer
102 views
Hi.
I´m facing scenario that i do not understand, and can not solve.

In RadToolBar1 I´ve added:
<telerik:RadToolBarButton Text="Delete" CommandName="DeletePost" PostBack="false" ImageUrl="Themes/Default/Icons/Telerik/Delete.png"></telerik:RadToolBarButton>

In RadGrid1 I´ve added:
<telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" CommandName="SelectPost" HeaderStyle-Width="40px" />

When client press button in RadToolBar1 with CommandName="DeletePost" , I want to run my server-side code that will delete selected row(s) from db. Ajaxified.

Markup:
<%@ Page Title="" Language="C#" MasterPageFile="App_master/MasterPage.master" AutoEventWireup="true"
    CodeFile="Posts.aspx.cs" Inherits="ccc_Posts" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <telerik:RadAjaxManager runat="server" ID="RadAjaxManager1" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                    <telerik:AjaxUpdatedControl ControlID="RadToolBar1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadToolBar1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel1">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadTreeView runat="Server" ID="RadTreeView1" EnableViewState="False" Style="margin-top: 4px;
        margin-left: 4px;">
    </telerik:RadTreeView>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="Server">
    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
        <script type="text/javascript">
            var toolbar;
            var grid;
 
            function pageLoad() {
                grid = $find("<%=RadGrid1.ClientID %>");
                toolbar = $find("<%= RadToolBar1.ClientID %>");
 
                if (grid.get_masterTableView().get_selectedItems().length == 0)
                    toolbar.findButtonByCommandName("DeletePost").disable();
 
            }
 
            function onGridRowSelected(sender, args) {
                toolbar.findButtonByCommandName("DeletePost").enable();
            }
 
            // Open window
            function OpenWindow(url) {
                radopen(url, "NewPost");
            }
 
            function OnClientButtonClickingHandler(sender, eventArgs) {
                if (eventArgs.get_item().get_value() == "NewPost") {
                    OpenWindow('NewPost.aspx');
                }
            }   
        </script>
    </telerik:RadScriptBlock>
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" Modal="true" Width="1024px"
        OnClientClose="closeRadWindow" Behaviors="Close, Reload, Resize, Move, Maximize"
        Height="710px" ViewStateMode="Disabled" ShowContentDuringLoad="false" VisibleStatusbar="false">
    </telerik:RadWindowManager>
    <telerik:RadSplitter runat="server" ID="RadSplitter1" Width="100%" BorderSize="0"
        BorderStyle="None" PanesBorderSize="0" Height="100%" Orientation="Horizontal">
        <telerik:RadPane runat="server" ID="RadPane1" Height="30px" EnableViewState="false"
            Scrollable="false">
            <telerik:RadToolBar runat="server" ID="RadToolBar1" EnableViewState="false" CssClass="inbox-search-toolbar"
                OnClientButtonClicking="OnClientButtonClickingHandler" OnButtonClick="RadToolBar1_ButtonClick">
                <Items>
                    <telerik:RadToolBarButton Text="New Post" Value="NewPost" PostBack="false" ImageUrl="Themes/Default/Icons/Telerik/Add.png">
                    </telerik:RadToolBarButton>
                    <telerik:RadToolBarButton IsSeparator="true" />
                    <telerik:RadToolBarButton Text="Delete" CommandName="DeletePost" PostBack="false" ImageUrl="Themes/Default/Icons/Telerik/Delete.png">
                    </telerik:RadToolBarButton>
                    <telerik:RadToolBarButton IsSeparator="true" />
                    <telerik:RadToolBarButton Value="searchTextBoxButton">
                        <ItemTemplate>
                            <telerik:RadTextBox runat="server" ID="blogToolBarSearchTb" EmptyMessage="Search Posts"
                                CssClass="inbox-search-textbox" Width="300px" />
                        </ItemTemplate>
                    </telerik:RadToolBarButton>
                    <telerik:RadToolBarButton ImageUrl="Themes/Default/Icons/16x16/search.png" Value="search" />
                </Items>
            </telerik:RadToolBar>
        </telerik:RadPane>
        <telerik:RadPane runat="server" ID="RadPane2">
            <telerik:RadGrid runat="server" ID="RadGrid1" AutoGenerateColumns="false" GridLines="None"
                AllowMultiRowSelection="true" Height="100%" BorderWidth="0px" AllowSorting="True"
                Style="outline: none" ShowGroupPanel="True">
                <ClientSettings Scrolling-AllowScroll="True" Scrolling-UseStaticHeaders="true" Selecting-AllowRowSelect="true"
                    EnablePostBackOnRowClick="false" AllowDragToGroup="true" EnableRowHoverStyle="true"
                    ClientEvents-OnRowSelected="onGridRowSelected">
                </ClientSettings>
                <MasterTableView TableLayout="Fixed" GroupLoadMode="Client" Width="100%">
                    <Columns>
                        <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" CommandName="SelectPost"
                            HeaderStyle-Width="40px" />
                        <telerik:GridTemplateColumn HeaderText="Title" UniqueName="BlogTitle" Groupable="false"
                            HeaderStyle-Width="100%">
                            <ItemTemplate>
                                <a href="#"><b>
                                    <%# Eval("Title")%></b></a>
                                <div style="margin: 4px 0px;">
                                    <asp:ImageButton ID="statusBtn" runat="server" ImageUrl="~/Themes/Default/Icons/16x16/finished-work2.png"
                                        Style="vertical-align: middle;" />
                                    <span style="vertical-align: middle; margin-left: 2px;">Status:</span>
                                </div>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn HeaderText="Action" UniqueName="BlogAction" HeaderStyle-Width="110px"
                            Groupable="false">
                            <ItemTemplate>
                                <div style="margin: 4px 0px;">
                                    <asp:ImageButton ID="actionBtn" runat="server" ImageUrl="~/Themes/Default/Icons/16x16/edit.png"
                                        Style="vertical-align: middle;" />
                                    <span style="vertical-align: middle; margin-left: 2px;"><a href="javascript:OpenWindow('NewPost.aspx?id=<%# Eval("BlogPostId")%>')">
                                        Edit</a></span>
                                </div>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn HeaderText="Comments" UniqueName="BlogComments" HeaderStyle-Width="85px"
                            Groupable="false">
                            <ItemTemplate>
                                <div style="margin: 4px 0px;">
                                    <span style="vertical-align: middle; margin-left: 2px;">(num)</span>
                                </div>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn HeaderText="User" UniqueName="BlogUserName" HeaderStyle-Width="170px"
                            GroupByExpression="Username Group by Username">
                            <ItemTemplate>
                                <div style="margin: 4px 0px;">
                                    <span style="vertical-align: middle; margin-left: 2px;">
                                        <%# Eval("Username")%></span>
                                </div>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn HeaderText="Blog Date" UniqueName="BlogDate" HeaderStyle-Width="150px"
                            GroupByExpression="BlogDate Group by BlogDate">
                            <ItemTemplate>
                                <div style="margin: 4px 0px;">
                                    <span style="vertical-align: middle; margin-left: 2px;">
                                        <%# Eval("BlogDate")%></span>
                                </div>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                    </Columns>
                </MasterTableView>
            </telerik:RadGrid>
        </telerik:RadPane>
    </telerik:RadSplitter>
    <script type="text/javascript">
        function closeRadWindow() {
            $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest();
        
    </script>
</asp:Content>

Code:
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CSSUtilityLib;
using CSSUtilityLib.Configuration;
using CSSUtilityLib.Cookie;
using CSSUtilityLib.DataAccess;
using CSSUtilityLib.Email;
using CSSUtilityLib.Process;
using CSSUtilityLib.Security;
using CSSUtilityLib.Transfer;
using CSSUtilityLib.Validation;
using System.Data;
using System.Data.SqlClient;
using Telerik.Web.UI;
 
public partial class ccc_Posts : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        // code layer for testing purpose
        string connStr = ConfigManager.GetConnStr("CSSBlogDB");
        DataSet ds0 = SqlServerDataAccessHelper.ExecuteDataSet(connStr, CommandType.StoredProcedure, "SelectAllBlogPost");
 
        RadGrid1.DataSource = ds0;
        RadGrid1.DataBind();
    }
    protected void RadToolBar1_ButtonClick(object sender, Telerik.Web.UI.RadToolBarEventArgs e)
    {
        string sCommand = e.Item.Text;
 
        switch (sCommand)
        {
            case "Delete":
                // Code here..
                break;
        }
    }
    protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
    {
        RadGrid1.Rebind();
    }
}
Iana Tsolova
Telerik team
 answered on 17 Oct 2011
9 answers
2.2K+ views
I use a RadGrid with ObjectDataSource. For most fields I use autoedit mode but for one field type of Int32 I added  EditItemTemplate with  telerik:RadNumericTextBox and bind it with  DbValue='<%# Bind("myField") %>'.
The update/insert throws an error "Object of type 'System.Double' cannot be converted to type 'System.Int32'".
How to fix the issue but still use the Bind() approach?
Iana Tsolova
Telerik team
 answered on 16 Oct 2011
1 answer
87 views
Hi All,
How to increase scheduler's header's height?
Stuart Hemming
Top achievements
Rank 2
 answered on 16 Oct 2011
1 answer
80 views
We have a project where we have been successfully using the radmenu with statically defined menuitems but due to page weight and exceptionally long js render times we are trying to use the webservice population mode.  We have the code running within our control in a test harness successfully but when we run within our sharepoint environment the server side onclick events are not being triggered.  These same onclick events are being caught in the debugger when running our code outside of sharepoint.  Using fiddler we see a postback does occur when the menu item is clicked. 

Do you have any suggestions on what to check/where to look next.

Thanks.

 

 

<telerik:RadMenu ID="xxxRadMenu" runat="server" Skin="Office2007" ClickToOpen="true"

 

 

 

OnClientItemClicking="DoIt.OnMenuItemClicking" OnItemClick="xxxRadMenu_ItemClicked"

 

 

 

CollapseAnimation-Type="None" CssClass="ActionsRadMenu" OnClientItemPopulating="itemPopulating">

 

 

 

<WebServiceSettings Method="PopulateAccountMenuItems" />

 

 

 

<Items>

 

 

 

<telerik:RadMenuItem Text="Actions..."

 

 

 

Value="Actions"

 

 

 

PostBack="false"

 

 

 

ExpandMode="WebService">

 

 

 

</telerik:RadMenuItem>

 

 

 

</Items>

 

 

 

</telerik:RadMenu>

 

Kalina
Telerik team
 answered on 16 Oct 2011
11 answers
312 views
We wanted to use something better than "title" property on our control to see a beautiful tooltip everywhere.

I saw that on the telerik documentation: (source Telerik documentation for autotooltipify property)
Gets or sets a value whether the RadToolTipManager, when its TargetControls collection is empty will tooltipify automatically all elements on the page that have a 'title' attribute   

Wonderful ! I only have to put a radtooltipmanager on my masterpage and every title will be converted to beautiful tooltip !

BUT ???

Ok, title are converted to tooltip.  But not only title, ALT also.  I have a lot <img src="..." alt="..."> tags on my pages and I do not want alt to be converted to tooltip !  How can I have only my TITLE property converted to tooltip, not my ALT property ?
Grant Henderson
Top achievements
Rank 1
 answered on 16 Oct 2011
2 answers
86 views
Hi,

I have a Sharepoint webpart wherein I use the RadPanelBar, However when I click on the arrows of the item header it doesnt expand or collapse but when I clicked on the other parts of the header it does expand /Collapse. Do I miss something in my code?

Thanks!

Regards,

Kunal
Kalina
Telerik team
 answered on 16 Oct 2011
5 answers
179 views
Hello,

I have a bit of an issue:

I have four ComboBoxes on the page as seen below:

<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="ddlCountry">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="ddlState" UpdatePanelHeight="" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="ddlState">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="ddlLocation" UpdatePanelHeight="" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="ddlLocation">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="ddlPostcode" UpdatePanelHeight="" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManagerProxy>
 
 
                    <table id="Table1" width="100%" class="style1">
                        <tr runat="server" width="150px" id="tr10">
                            <td>
                                Country 
                            </td>
                            <td>
                                <telerik:RadComboBox ID="ddlCountry" runat="server" OnSelectedIndexChanged="ddlCountry_SelectedIndexChanged"
                                    Width="300px" EnableLoadOnDemand="True" AutoPostBack="True">
                                </telerik:RadComboBox>
                                <asp:RequiredFieldValidator ID="rfvCountry" runat="server" ErrorMessage="*" ControlToValidate="ddlCountry"
                                    ValidationGroup="Customer"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr runat="server" id="trState">
                            <td>
                                State 
                            </td>
                            <td>
                                <telerik:RadComboBox ID="ddlState" OnSelectedIndexChanged="ddlState_SelectedIndexChanged"
                                    Width="300px" runat="server" AutoPostBack="True">
                                </telerik:RadComboBox>
                                <asp:RequiredFieldValidator ID="rfvState" runat="server" ErrorMessage="*" ControlToValidate="ddlState"
                                    ValidationGroup="Customer"></asp:RequiredFieldValidator>
                            </td>
                            <td>
                                Location 
                            </td>
                            <td>
                                <telerik:RadComboBox ID="ddlLocation" OnSelectedIndexChanged="ddlLocation_SelectedIndexChanged"
                                    Width="300px" runat="server" AutoPostBack="True">
                                </telerik:RadComboBox>
                                <asp:RequiredFieldValidator ID="rfvLocation" runat="server" ErrorMessage="*" ControlToValidate="ddlLocation"
                                    ValidationGroup="Customer"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr runat="server" id="trPostcode">
                            <td>
                                Postcode 
                            </td>
                            <td>
                                <telerik:RadComboBox ID="ddlPostcode" runat="server" Width="300px">
                                </telerik:RadComboBox>
                                <asp:RequiredFieldValidator ID="rfvPostcode" runat="server" ErrorMessage="*" ControlToValidate="ddlPostcode"
                                    ValidationGroup="Customer"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                    </table>

all data-bound from c# like so (including selected index changed);

#region Location ddls
private void BindCountry()
{
    string sql = "SELECT DISTINCT LookupID_LookupTable, LookupID, LookupParentID FROM " + XDEV.xd_Schema.ToString() + "xd_lookup_tables WHERE (LookupParentID = 41)";
    DataTable dt = data.GetDataTable(sql);
    if (dt.Rows.Count > 0)
    {
        ddlCountry.DataSource = dt;
        ddlCountry.DataTextField = "LookupID_LookupTable";
        ddlCountry.DataValueField = "LookupID";
        ddlCountry.DataBind();
        //RadAjaxManager1.FocusControl(ddlCountry);
    }
}
private void BindState(string country)
{
    string sql = string.Format("SELECT DISTINCT LookupID_LookupTable, LookupID, LookupParentID FROM " + XDEV.xd_Schema.ToString() + "xd_lookup_tables WHERE ( LookupID_ParentLookupID ={0})", country);
    DataTable dt = data.GetDataTable(sql);
    if (dt.Rows.Count > 0)
    {
        ddlState.DataSource = dt;
        ddlState.DataTextField = "LookupID_LookupTable";
        ddlState.DataValueField = "LookupID";
        ddlState.DataBind();
        //RadComboBoxItem StateItem = new RadComboBoxItem("- Select a State -", "0"); //Creates new item for RadCombobox 
        //ddlState.Items.Add(StateItem);
    }
}
private void BindLocation(string state)
{
    string sql = string.Format("SELECT DISTINCT LookupID_LookupTable, LookupID, LookupParentID FROM " + XDEV.xd_Schema.ToString() + "xd_lookup_tables WHERE ( LookupID_ParentLookupID = {0})", state);
    DataTable dt = data.GetDataTable(sql);
    if (dt.Rows.Count > 0)
    {
        ddlLocation.DataSource = dt;
        ddlLocation.DataTextField = "LookupID_LookupTable";
        ddlLocation.DataValueField = "LookupID";
        ddlLocation.DataBind();
        //RadComboBoxItem LocationItem = new RadComboBoxItem("- Select a Location -", "0"); //Creates new item for RadCombobox 
        //ddlLocation.Items.Add(LocationItem);
    }
}
private void BindPostcode(string location)
{
    string sql = string.Format("SELECT DISTINCT LookupID_LookupTable, LookupID, LookupParentID FROM " + XDEV.xd_Schema.ToString() + "xd_lookup_tables WHERE ( LookupID_ParentLookupID = {0})", location);
    DataTable dt = data.GetDataTable(sql);
    if (dt.Rows.Count > 0)
    {
        ddlPostcode.DataSource = dt;
        ddlPostcode.DataTextField = "LookupID_LookupTable";
        ddlPostcode.DataValueField = "LookupID";
        ddlPostcode.DataBind();
        //RadComboBoxItem PostcodeItem = new RadComboBoxItem("- Select a Postcode -", "0"); //Creates new item for RadCombobox 
        //ddlPostcode.Items.Add(PostcodeItem);
    }
}
 
protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)
{
    BindState(ddlCountry.SelectedValue);
}
 
protected void ddlState_SelectedIndexChanged(object sender, EventArgs e)
{
    BindLocation(ddlState.SelectedValue);
}
protected void ddlLocation_SelectedIndexChanged(object sender, EventArgs e)
{
    BindPostcode(ddlLocation.SelectedValue);
}
#endregion

and the existing records are bound like so:

#region cascading ddls
if (!String.IsNullOrEmpty(dt.Rows[0]["LookupID_Country"].ToString()))
{
    if (ddlCountry.Items.Contains(ddlCountry.Items.FindItemByValue(dt.Rows[0]["LookupID_Country"].ToString())))
    {
        ddlCountry.SelectedValue = dt.Rows[0]["LookupID_Country"].ToString();
        BindCountry();
    }
}
if (!String.IsNullOrEmpty(dt.Rows[0]["LookupID_State"].ToString()))
{
    if (ddlState.Items.Contains(ddlState.Items.FindItemByValue(dt.Rows[0]["LookupID_State"].ToString())))
    {
        ddlState.SelectedValue = dt.Rows[0]["LookupID_State"].ToString();
        BindState(ddlCountry.SelectedValue);
    }
    else
    {
         
    }
}
if (!String.IsNullOrEmpty(dt.Rows[0]["LookupID_Location"].ToString()))
{
    if (ddlLocation.Items.Contains(ddlLocation.Items.FindItemByValue(dt.Rows[0]["LookupID_Location"].ToString())))
    {
        ddlLocation.SelectedValue = dt.Rows[0]["LookupID_Location"].ToString();
        BindLocation(ddlState.SelectedValue);
    }
}
if (!string.IsNullOrEmpty(dt.Rows[0]["LookupID_Postcode"].ToString()))
{
    if (ddlPostcode.Items.Contains(ddlPostcode.Items.FindItemByValue(dt.Rows[0]["LookupID_Postcode"].ToString())))
    {
        ddlPostcode.SelectedValue = dt.Rows[0]["LookupID_Postcode"].ToString();
        BindPostcode(ddlLocation.SelectedValue);
    }
}
#endregion);
what is currently occurring is the first ComboBox is being bound with the record but the other 3  are blank where they should display the records from the db.

What needs to happen is when the user clicks 'Edit' button the user control becomes visible with ComboBoxes displaying the existing(non-edited data) and allow the user to change the ComboBox selected value.
Trent
Top achievements
Rank 2
 answered on 16 Oct 2011
2 answers
90 views
Hello Telerik,

I have an embedded imagebutton in a RadGrid with grouping, the grid has an Item command as follows:

# region Radgrid code
 
   protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
   {
       if (e.CommandName == "Select")
       {
           //Session.Add("CustomerID", e.Item.Cells[3].Text.ToString());
           Geek.XTV7_Videos_ID = e.Item.Cells[4].Text.ToString();
       }
   }
 
   #endregion

the image button code is as follows 
xt_Imagebutton.ascx
<asp:ImageButton ID="btnImageDisplay" runat="server" CommandName="Select" OnClick="Image_Click" Width="120px" />
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" />
xt_Imagebutton.ascx.cs
public string source
{
    get
    {
        return btnImageDisplay.ImageUrl;
    }
    set
    {
        btnImageDisplay.ImageUrl = value;
    }
}
protected void Image_Click(object sender, ImageClickEventArgs e)
{
      
    ReturnImages(Geek.XTV7_Videos_ID.ToString());
}
#region SQLCommands
public void ReturnImages(string VideoID)
{
    if (!String.IsNullOrEmpty(Geek.XTV7_Videos_ID.ToString()))
    {
        string sql = "";
        var dt = new DataTable();
        sql += string.Format("Select [XTV7_Videos_Image] From Xtrain.XTV7_2_Videos WHERE  (XTV7_Videos_ID= {0})", VideoID);
        dt = data.GetDataTable(sql);
        if (dt.Rows.Count > 0)
        {
            Geek.XTV7_Image = (dt.Rows[0]["XTV7_Videos_Image"].ToString()).ToString();
            RadAjaxManager1.ResponseScripts.Add("radopen('Forms/View/ImageViewer.aspx','RadWindow2')");
 
        }
        dt.Dispose();
    }
}
#endregion
VideoSelector.ascx
<telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True" AutoGenerateColumns="False"
    BackColor="White" CellSpacing="0" DataSourceID="SqlDataSource2" EnableLinqExpressions="False"
    GridLines="None" Height="650px" AllowPaging="True" PageSize="4" OnItemCommand="RadGrid1_ItemCommand"
    ShowGroupPanel="True">
    <ClientSettings EnablePostBackOnRowClick="true">
        <Selecting AllowRowSelect="True" />
        <ClientEvents OnRowSelected="RowSelected" />
        <Scrolling AllowScroll="True" UseStaticHeaders="True" />
    </ClientSettings>
    <MasterTableView AllowMultiColumnSorting="true" DataKeyNames="XTV7_Videos_ID,XTV7_Videos_Image"
        DataSourceID="SqlDataSource2" ShowGroupFooter="false" Summary="Video Lessons">
        <CommandItemSettings ExportToPdfText="Export to PDF" />
        <GroupByExpressions>
            <telerik:GridGroupByExpression>
                <SelectFields>
                    <telerik:GridGroupByField FieldAlias=":" FieldName="XTV7_Categories_Name" />
                    <telerik:GridGroupByField FieldAlias="SubCategory" FieldName="XTV7_Categories_Sub_Name" />
                </SelectFields>
                <GroupByFields>
                    <telerik:GridGroupByField FieldName="XTV7_Videos_Date_Uploaded" HeaderText="Sort By Date Uploaded"
                        SortOrder="Descending" />
                </GroupByFields>
            </telerik:GridGroupByExpression>
        </GroupByExpressions>
        <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
        </RowIndicatorColumn>
        <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
        </ExpandCollapseColumn>
        <Columns>
            <telerik:GridTemplateColumn AllowFiltering="false" HeaderStyle-Width="110px" HeaderText="Lesson Snapshot"
                ItemStyle-Width="110px" SortExpression="XTV7_Categories_Image" UniqueName="XTV7_Categories_Sub_Image">
                <ItemTemplate>
                    <%--                            <asp:ImageButton ID="btnImageDisplay" runat="server" CommandName="Select" ImageUrl='<%# "~/App_Portal/xTrain/Images/VideoImages/" + Eval("XTV7_Videos_Image") %>' OnClick="Image_Click" Width="120px" />--%>
                    <xTrain:xImgButton ID="xt_ImageButton1" runat="server" source='<%# "~/App_Portal/xTrain/Images/VideoImages/" + Eval("XTV7_Videos_Image") %>' />
                </ItemTemplate>
                <HeaderStyle Width="130px" />
                <ItemStyle Width="110px" />
            </telerik:GridTemplateColumn>
            <telerik:GridBoundColumn DataField="XTV7_Videos_ID" DataType="System.Int32" FilterControlAltText="Filter XTV7_Videos_ID column"
                HeaderText="ID" ItemStyle-Width="20px" ReadOnly="False" SortExpression="XTV7_Videos_ID"
                UniqueName="XTV7_Videos_ID" Visible="False">
                <ItemStyle Width="20px" />
            </telerik:GridBoundColumn>
            <telerik:GridTemplateColumn AllowFiltering="false" HeaderStyle-Width="50px" ItemStyle-Width="50px">
                <ItemTemplate>
                    <asp:ImageButton ID="imgbtnStartVideo" runat="server" CommandName="Select" ImageUrl="~/App_Themes/XGIS/Images/LessonLevels/PlayVideo32.png"
                        ToolTip="Play Video" />
                </ItemTemplate>
                <HeaderStyle Width="50px" />
                <ItemStyle Width="50px" />
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn AllowFiltering="false" HeaderStyle-Width="50px" ItemStyle-Width="50px">
                <ItemTemplate>
                    <asp:ImageButton ID="imgbtnStartVideoIPOD" runat="server" CommandName="Select" ImageUrl="~/App_Themes/XGIS/Images/LessonLevels/IPAD30.png"
                        ToolTip="Podcast" />
                </ItemTemplate>
                <HeaderStyle Width="50px" />
                <ItemStyle Width="50px" />
            </telerik:GridTemplateColumn>
            <telerik:GridBoundColumn Aggregate="Count" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"
                DataField="XTV7_Videos_Title" EmptyDataText="Search Titles" FilterControlToolTip="Search Titles"
                FilterControlWidth="200px" FooterText="Videos: " HeaderStyle-Width="240px" HeaderText="Search Video Titles"
                ItemStyle-Width="50px" ItemStyle-Wrap="true" SortExpression="XTV7_Videos_Title"
                UniqueName="XTV7_Videos_Title">
                <HeaderStyle Width="240px" />
                <ItemStyle Width="50px" Wrap="True" />
            </telerik:GridBoundColumn>
            <telerik:GridTemplateColumn AllowFiltering="false" DataField="XTV7_Videos_Difficulty"
                DataType="System.Int32" HeaderText="Difficulty" ItemStyle-Width="20px" SortExpression="XTV7_Videos_Difficulty"
                UniqueName="XTV7_Videos_Difficulty">
                <ItemTemplate>
                    <asp:Image ID="imgD" runat="server" ImageUrl='<%# GetImageUrl((int)Eval("XTV7_Videos_Difficulty")) %>' />
                </ItemTemplate>
                <ItemStyle Width="20px" />
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn AllowFiltering="false" DataField="XTV7_Videos_Captions"
                DataType="System.Byte" HeaderText="Captions" ItemStyle-Width="20px" SortExpression="XTV7_Videos_Captions"
                UniqueName="XTV7_Videos_Captions">
                <ItemTemplate>
                    <asp:Image ID="imgCaption" runat="server" ImageUrl='<%# (bool)Eval("XTV7_Videos_Captions") ? "~/App_Themes/XGIS/images/boolean/true.gif" : "~/App_Themes/XGIS/images/boolean/false.gif" %>' />
                </ItemTemplate>
                <ItemStyle Width="20px" />
            </telerik:GridTemplateColumn>
            <telerik:GridBoundColumn AllowFiltering="False" DataField="XTV7_VideoHits" DataType="System.Int32"
                FilterControlAltText="Filter XTV7_VideoHits column" HeaderText="Hits" SortExpression="XTV7_VideoHits"
                UniqueName="XTV7_VideoHits">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="XTV7_Videos_FileName" DataType="System.String"
                HeaderText="Hits" SortExpression="XTV7_Videos_FileName" UniqueName="XTV7_Videos_FileName"
                Visible="false">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="XTV7_Videos_Date_Uploaded" DataFormatString="{0:d}"
                DataType="System.DateTime" HeaderText="Uploaded" SortExpression="XTV7_Videos_Date_Uploaded"
                UniqueName="XTV7_Videos_Date_Uploaded" Visible="false">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="XTV7_Categories_Name" HeaderText="XTV7_Categories_Name"
                SortExpression="XTV7_Categories_Name" UniqueName="XTV7_Categories_Name" Visible="false">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="XTV7_Categories_Sub_Name" HeaderText="XTV7_Categories_Sub_Name"
                SortExpression="XTV7_Categories_Sub_Name" UniqueName="XTV7_Categories_Sub_Name"
                Visible="false">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="XTV7_Categories_ID" DataType="System.Int32" HeaderText="XTV7_Categories_ID"
                SortExpression="XTV7_Categories_ID" UniqueName="XTV7_Categories_ID" Visible="false"
                ReadOnly="false">
            </telerik:GridBoundColumn>
        </Columns>
        <EditFormSettings>
            <EditColumn FilterControlAltText="Filter EditCommandColumn column">
            </EditColumn>
        </EditFormSettings>
    </MasterTableView>
    <PagerStyle EnableSEOPaging="True" PageButtonCount="20" />
    <FilterMenu EnableImageSprites="False">
    </FilterMenu>
    <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Black">
    </HeaderContextMenu>
</telerik:RadGrid>

What I am attempting to acheive is when the button's OnClick event is fired I want RadGrid1_ItemCommand to extract the MasterKeyValue of the Select command and pass the ID to the session variable XTV7_Videos_ID that is managed by the Session Handler GEEK (Geek.XTV7_Videos_ID)

The issue exists when the OnClick event is fired, for some reason the RadGrid1_ItemCommand does not get fired until after the OnClick event method is complete. so there for the CommandName="Select" is not occuring until after the fact.

How can I resolve this problem and get the ItemCommand firering as soon as the CommandName is hit or can I call/trigger the ItemCommand from the OnClick event?

Ever so grateful, 
Trent



Trent
Top achievements
Rank 2
 answered on 16 Oct 2011
1 answer
113 views
Hello,
I have a radgrid that contains a detailstable. When I have to delete a parent record, no problem to get datakeyvalues. When I try to delete a child record, I am able to get DataKeyNames but DataKeyValues is empty!

The definition of DetailsTable is this:
         <DetailTables>
            <telerik:GridTableView name="Partecipanti" TableLayout="Fixed" DataKeyNames="PortalID,UserID,CodRiunione" AllowFilteringByColumn="false"
                DataSourceID="objDataSourceGridPartecipantiRiunione" Width="60%" HorizontalAlign="Right"
                ShowFooter="false" ShowGroupFooter="false" AllowCustomSorting="false" AllowCustomPaging="false"
                CommandItemSettings-AddNewRecordText="Conferma / Rifiuta partecipazione" CommandItemDisplay="Top"
                CommandItemSettings-ShowRefreshButton="false"
                runat="server">
                <ParentTableRelation>
                    <telerik:GridRelationFields DetailKeyField="PortalID,CodRiunione" MasterKeyField="PortalID,ItemID" />
                </ParentTableRelation>
                <Columns>
                    <telerik:GridBoundColumn Visible="false" HeaderText="PortalID" AllowFiltering="false"
                        DataField="PortalID" UniqueName="PortalID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn Visible="false" HeaderText="UserID" AllowFiltering="false"
                        DataField="UserID" UniqueName="UserID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn Visible="false" HeaderText="CodRiunione" AllowFiltering="false"
                        DataField="CodRiunione" UniqueName="CodRiunione">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn HeaderStyle-Width="200" HeaderText="Partecipanti" AllowFiltering="false"
                        DataField="Nominativo" UniqueName="Nominativo">
                    </telerik:GridBoundColumn>
                    <telerik:GridCheckBoxColumn Visible="false" HeaderText="FlgConfermaPartecipazione"
                        AllowFiltering="false" DataField="FlgConfermaPartecipazione" UniqueName="FlgConfermaPartecipazione">
                    </telerik:GridCheckBoxColumn>
                    <telerik:GridBoundColumn HeaderStyle-Width="120" HeaderText="Stato" AllowFiltering="false"
                        DataField="ConfermaPartecipazioneTestuale" UniqueName="ConfermaPartecipazioneTestuale">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn HeaderText="Note" AllowFiltering="false" DataField="Note" MaxLength="150"
                        UniqueName="Note">
                    </telerik:GridBoundColumn>
                    <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Edit" Text="Modifica"
                        UniqueName="EditDetailCommandColumn" HeaderStyle-Width="30">
                        <HeaderStyle Width="30px"></HeaderStyle>
                        <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                    </telerik:GridButtonColumn>
                    <telerik:GridButtonColumn ConfirmText="Sei sicuro di voler eliminare il partecipante da questa riunione?"
                        ConfirmDialogType="Classic" ConfirmTitle="Conferma cancellazione" ButtonType="ImageButton"
                        CommandName="Delete" Text="Elimina" UniqueName="DeleteDetailColumn" HeaderStyle-Width="30">
                        <HeaderStyle Width="30px"></HeaderStyle>
                        <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                    </telerik:GridButtonColumn>
                </Columns>
                <EditFormSettings EditFormType="Template">
                    <FormTemplate>
                        <table border="0" cellspacing="2" cellpadding="1" width="100%" border="1" rules="none"
                            style="border-collapse: collapse">
                            <tr class="EditFormHeader">
                                <td colspan="2">
                                    <b>Conferma / Rifiuta partecipazione</b>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <table border="0" cellspacing="1" cellpadding="1" width="100%" border="0">
                                        <tr>
                                            <td>
                                                Utente:
                                            </td>
                                            <td>
                                                <telerik:RadComboBox ID="RadComboBoxUtente" runat="server" DataSourceID="objDataSourceUtentiUfficialiNonUfficialiGDL"
                                                    Filter="Contains" DataTextField="NominativoConFlagPredefinito" Width="400" DataValueField="UserID"
                                                    SelectedValue='<%# Bind("UserID") %>'>
                                                </telerik:RadComboBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                Presenza:
                                            </td>
                                            <td>
                                                <telerik:RadComboBox ID="RadComboBoxPartecipazione" Width="150" runat="server" SelectedValue = '<%# Bind("FlgConfermaPartecipazione") %>' OnDataBinding="RadComboBoxPartecipazione_OnDataBinding">
                                                    <Items>
                                                        <telerik:RadComboBoxItem Text="Parteciperò" Value="1"   />
                                                        <telerik:RadComboBoxItem Text="Non parteciperò" Value="0"  />
                                                    </Items>
                                                </telerik:RadComboBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                Note:
                                            </td>
                                            <td>
                                                <asp:TextBox ID="txtNote" MaxLength="150" Width="300" runat="server" Text='<%# Bind("Note") %>'>
                                                </asp:TextBox>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td align="right" colspan="2">
                                    <br /><br />
                                    <telerik:RadButton ID="btnUpdate" runat="server" Text='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "Inserisci", "Aggiorna") %>'
                                        CssClass="MyImageButton" CommandName='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "PerformInsert", "Update")%>'>
                                    </telerik:RadButton>
                                    <telerik:RadButton ID="btnCancel" Text="Annulla" runat="server" CausesValidation="False"
                                        CommandName="Cancel">
                                    </telerik:RadButton>
                                </td>
                            </tr>
                        </table>
                        <asp:HiddenField ID="hidUserID" runat="server" Value='<%# UserID %>' />
                    </FormTemplate>
                    <EditColumn UniqueName="EditCommandColumn1" FilterControlAltText="Filter EditCommandColumn1 column">
                    </EditColumn>
                </EditFormSettings>
                <NoRecordsTemplate>
                    Nessun partecipante per questa riunione
                </NoRecordsTemplate>
            </telerik:GridTableView>
        </DetailTables>

and this is the line I use to retrieve datakeyvalues:
DirectCast(DirectCast(rdgrd_Agenda, Telerik.Web.UI.RadGrid).MasterTableView.DetailTables(0),Telerik.Web.UI.GridTableView).DataKeyValues(e.Item.ItemIndex)("UserID")

The array as Count=0. Where I am wrong?
Thanks
Mario
Top achievements
Rank 1
 answered on 15 Oct 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Top achievements
Rank 1
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ivory
Top achievements
Rank 1
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
YF
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Top achievements
Rank 1
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ivory
Top achievements
Rank 1
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
YF
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?