Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
132 views
hello
i have 4 main control, a radcombobox, radlistview with a asp button, and a label, i want to filter radlistview data by radcombobox selected value,( i do it without  problem), and after click on asp button in radlistview, that return datakey with button commandargument value to label, but my problem is after click on asp button, label show nothing.
RadComboBox code:
aspx:
<telerik:RadComboBox ID="CityDDL" runat="server"
     AutoPostBack="true" Label="City :" Skin="Default" />
cs:
protected void LoadCities()
{
    SqlConnection connection = new SqlConnection(
    ConfigurationManager.ConnectionStrings["SiteSqlServer1"].ConnectionString);
     SqlDataAdapter adapter = new SqlDataAdapter(@"", connection);
    DataTable dt = new DataTable();
    adapter.Fill(dt);
     CityDDL.DataTextField = "Name";
    CityDDL.DataValueField = "ID";
    CityDDL.DataSource = dt;
    CityDDL.DataBind();
    // Insert the first item.
    CityDDL.Items.Insert(0, new RadComboBoxItem("- Select City -"));
}

RadListView Code:
aspx:
<telerik:RadListView ID="RadListView1" runat="server" DataSourceID="SqlDataSource1"
    ItemPlaceholderID="ListViewContainer" AllowPaging="True" PageSize="12"
        onprerender="RadListView1_PreRender">
    <LayoutTemplate>                    
               <asp:PlaceHolder runat="server" id="ListViewContainer" />
    </LayoutTemplate>
    <ItemTemplate>
        <fieldset style="float: left; width: 266px; height: 260px;">
            <legend><b>State Name:</b>: <%#Eval("Name")%></legend>
            <div class="details">                           
                            <asp:Button ID="SelectStateID" OnClick="SelectStateID_Click"
CommandArgument='<%# Eval("ID") %>' runat="server" Text="Select State"  />
                <div class="data-container">
                    <ul>
                        <li>
                            <label>
                                State Code:
                            <%#Eval("Code")%>                          
                        </li>                       
                    </ul>                                        
                </div>
            </div>
        </fieldset>
    </ItemTemplate>
</telerik:RadListView>

cs:
protected void RadListView1_PreRender(object sender, EventArgs e)
{
    foreach (RadListViewItem item in RadListView1.Items)
    {
        Button lnk = item.FindControl("SelectStateID") as Button;
        RadAjaxManager1.AjaxSettings.AddAjaxSetting(lnk, Label1);
    }
}

ASP Button Code:
cs:
protected void SelectStateID_Click(object sender, EventArgs e)
{   
    var argument = ((Button)sender).CommandArgument;
    Label1.Text = argument.ToString();
}

RadAjaxManager Code:
aspx:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
         <AjaxSettings>
             <telerik:AjaxSetting AjaxControlID="CityDDL" EventName="SelectedIndexChanged">
                 <UpdatedControls>
                     <telerik:AjaxUpdatedControl ControlID="RadListView1" />
                 </UpdatedControls>
             </telerik:AjaxSetting>
         <telerik:AjaxSetting AjaxControlID="SelectStateID" EventName="SelectStateID_Click">
                 <UpdatedControls>
                     <telerik:AjaxUpdatedControl ControlID="Label1" />                                       
                 </UpdatedControls>
             </telerik:AjaxSetting>
        </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
            <asp:Image ID="Image1" runat="server" ImageUrl="~/images/WebResource.axd.gif" AlternateText="Loading..." />
        </telerik:RadAjaxLoadingPanel>

ASP Label:
aspx:
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

please help me.
thanks
Andrey
Telerik team
 answered on 06 Dec 2012
5 answers
612 views
Hi,

I installed the "RadControls for ASP.NET AJAX Q3 2012". I am using sharepoint 2010. I added the Rad grid in the visual webpart and bound the columns.  I used the below code:
<telerik:RadGrid ID="RadGrid1" runat="server" Visible="true" ShowHeader="true" ShowFooter="true" >
    <MasterTableView DataKeyNames="Title" AutoGenerateColumns="false">
                    <Columns>
                        <telerik:GridBoundColumn DataField="Title" HeaderText="Product Number" UniqueName="ProductNumber">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Description" HeaderText="Description" UniqueName="Description">
                        </telerik:GridBoundColumn>
  </Columns>
    </MasterTableView>
    </telerik:RadGrid>
I am able to bind the existing data in the databind code using c#. Few questions:
1) How to insert new data?
2) Also above the header and below the footer, is it possible to add a option as "Add new item" clicking on this, the textbox within the grid become editable?
3) Limit the number of items which can be added in the grid to 5.

How to achieve this?
Thanks
Andrey
Telerik team
 answered on 06 Dec 2012
1 answer
89 views
Hi,

I am attaching a Contextmenu to Listview. This is 2 level composite Context menu (contextmenu.jpg). Below is my source for building Contextmenu

<telerik:RadContextMenu ID="RadMenu1" runat="server" EnableRoundedCorners="true" EnableShadows="true" OnClientShowing="LoadContextMenu">
           <Items>
               <telerik:RadMenuItem Text="Accounting">
                   <Items>
                       <telerik:RadMenuItem Text="Sub Menu">
                           <ItemTemplate>
                               <telerik:RadTextBox ID="txtDecimal" Text="2" Label="Decimals" runat="server" Width="70px"
                                   MaxLength="2">
                               </telerik:RadTextBox>
                               <telerik:RadListBox ID="rlbcm1" runat="server" CheckBoxes="true">
                                   <Items>
                                       <telerik:RadListBoxItem Text="Include Commas" Value="Include Commas" />
                                       <telerik:RadListBoxItem Text="Include $ Sign" Value="Include $ Sign" />
                                   </Items>
                               </telerik:RadListBox>
                               <b>Negative Number</b>
                               <asp:RadioButtonList ID="rbNegativeNumber" runat="server" RepeatDirection="Vertical">
                                   <asp:ListItem Text="Use Brackets" Value="1"></asp:ListItem>
                                   <asp:ListItem Text="Use Negative Number" Value="2"></asp:ListItem>
                               </asp:RadioButtonList>
                           </ItemTemplate>
                       </telerik:RadMenuItem>
                   </Items>
               </telerik:RadMenuItem>
               <telerik:RadMenuItem Text="Date">
                   <Items>
                       <telerik:RadMenuItem Text="Sub Menu">
                           <ItemTemplate>
                               <asp:RadioButtonList ID="rbDateFormat" runat="server" RepeatDirection="Vertical">
                                   <asp:ListItem Text="01/05/2012" Value="1"></asp:ListItem>
                                   <asp:ListItem Text="Jan 05, 2012" Value="2"></asp:ListItem>
                                   <asp:ListItem Text="2012-01-05" Value="3"></asp:ListItem>
                                   <asp:ListItem Text="Custom" Value="4"></asp:ListItem>
                               </asp:RadioButtonList>
                           </ItemTemplate>
                       </telerik:RadMenuItem>
                   </Items>
               </telerik:RadMenuItem>
               <telerik:RadMenuItem Text="Percentage">
                   <Items>
                       <telerik:RadMenuItem Text="Sub Menu">
                           <ItemTemplate>
                               <telerik:RadTextBox ID="txtPercentageDecimal" Text="2" Label="Decimals" runat="server"
                                   Width="70px" MaxLength="2">
                               </telerik:RadTextBox>
                               <telerik:RadListBox ID="rlbpercentage" runat="server" CheckBoxes="true">
                                   <Items>
                                       <telerik:RadListBoxItem Text="% symbol" Value="% symbol" />
                                   </Items>
                               </telerik:RadListBox>
                           </ItemTemplate>
                       </telerik:RadMenuItem>
                   </Items>
               </telerik:RadMenuItem>
               <telerik:RadMenuItem Text="Text">
                   <Items>
                       <telerik:RadMenuItem Text="Sub Menu">
                           <ItemTemplate>
                               <asp:RadioButtonList ID="rbText" runat="server" RepeatDirection="Vertical">
                                   <asp:ListItem Text="Case as input" Value="1"></asp:ListItem>
                                   <asp:ListItem Text="All Caps" Value="2"></asp:ListItem>
                               </asp:RadioButtonList>
                           </ItemTemplate>
                       </telerik:RadMenuItem>
                   </Items>
               </telerik:RadMenuItem>
           </Items>          
       </telerik:RadContextMenu>
   </div>
   <telerik:RadAjaxManager ID="RadAjaxManager" runat="server" OnAjaxRequest="RadAjaxManager_AjaxRequest">
       <AjaxSettings>
           <telerik:AjaxSetting AjaxControlID="RadAjaxManager">
               <UpdatedControls>
                   <telerik:AjaxUpdatedControl ControlID="RadMenu1" LoadingPanelID="RadAjaxLoadingPanel" />
               </UpdatedControls>
           </telerik:AjaxSetting>
       </AjaxSettings>
   </telerik:RadAjaxManager>
   <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel" runat="server" Skin="Vista">      
   </telerik:RadAjaxLoadingPanel>

As you can see I have composite contextmenu which contains various server controls inside it (i.e Textbox, Listbox, Radiobutton).

Now I want to populate these contextmenu control with the dynamic values based on right clicked listview item. So for that I am performing an OnAjaxRequest="RadAjaxManager_AjaxRequest" request on OnClientShowing="LoadContextMenu" client event of Contextmenu.

Now the issue is that OnClientShowing event it is going to RadAjaxManager_AjaxRequest server request & performing all the server side update on context menu.
But the contextmenu is not repainted at clientside. i.e After server side processing, it is not showing on browser.
function LoadContextMenu(menu, args) {
                if (listItemIndex) {
                    InitiateAsyncRequest(listItemIndex);
                }
            }
 
function InitiateAsyncRequest(argument) {
                var ajaxManager = $find("<%= RadAjaxManager.ClientID %>");
                ajaxManager.ajaxRequest(argument);
                return false;
            }

Can you please help me how to reshow / repaint the contextmenu after AjaxRequest is performed.
Navnit
Top achievements
Rank 1
 answered on 06 Dec 2012
3 answers
253 views
Hello,

I am facing lot of problem creating GridTemplateColumn dynamically, i tried it using implementing ITemplate interface but was not successful.

I have other columns too in grid, which i create dynamically and do databinding also dynamically which works perfect,

Please can someone help me through this, its urgent.

Thanks in advance!

with regards,
Peeyush pandey
<telerik:GridTemplateColumn AllowFiltering="False" UniqueName="columnAction"  >
    <HeaderStyle Width="30px" />
    <HeaderTemplate>
        <asp:Label ID="lblHeaderAction" runat="server" Text="Action"></asp:Label>
    </HeaderTemplate>
    <ItemTemplate>
        <asp:Panel ID="editButtonPanel" runat="server" CssClass="custom-Action-column" Width="50px">
            <asp:ImageButton ID="TagCloudButton" runat="server"  Width="15px"
                Height="15px" CommandName="TagCloud"   CausesValidation="False" ImageUrl="~/images/icon_grid.gif" />
        </asp:Panel>
    </ItemTemplate>
</telerik:GridTemplateColumn>
 
 
 <telerik:GridTemplateColumn AllowFiltering="False" UniqueName="ProfileImage"  >
    <HeaderStyle Width="50px" />
    <HeaderTemplate>
        <asp:Label ID="lblHeaderActionImage" runat="server" Text="Image"></asp:Label>
    </HeaderTemplate>
    <ItemTemplate>
     <asp:Panel ID="ImagePanelPos" runat="server" CssClass="custom-Action-column" Width="50px">
        <asp:Image ID="Image1" runat="server" Height="35px" Width="35px" ImageUrl='<%#Convert.ToString(Eval("Url")) %>' />
        </asp:Panel>
    </ItemTemplate>
</telerik:GridTemplateColumn>
 
Shinu
Top achievements
Rank 2
 answered on 06 Dec 2012
1 answer
168 views
How to access RadListBox header Templet elements in server side and  in ItemDataBound?
Princy
Top achievements
Rank 2
 answered on 06 Dec 2012
3 answers
91 views

Hello,

i have a GridDropDownColumn connected to a DataSource and i get an error when i try to set the ListTextField property like this: ListTextField = "Field1, Field2". How can i achieve this programmatically in radgrid view mode?

I have written the following code to achieve this in radgrid edit mode:

if (e.Item is GridEditableItem && e.Item.IsInEditMode)
       {
 
           GridEditableItem editItem = (GridEditableItem)e.Item;
 
           RadComboBox combo = (RadComboBox)editItem["Field1"].Controls[0];
 
           combo.ItemDataBound += new RadComboBoxItemEventHandler(combo_ItemDataBound);
 
       }
 
   void combo_ItemDataBound(object sender, RadComboBoxItemEventArgs e)
   {
       RadComboBoxItem item = (RadComboBoxItem)e.Item;
 
       DataRowView dr = (DataRowView)e.Item.DataItem;
 
       item.Text = item.Text + " ( " + dr["Field2"].ToString() + " " + dr["Field3"].ToString() + " ) ";
 
   }

Thank you very much.

Princy
Top achievements
Rank 2
 answered on 06 Dec 2012
1 answer
133 views
Hi

I have inherited a site with a lot of Telerik components, and I'm having trouble with adding a PageSizeComboBox to a RadGrid. 

For some reason the ComboBox doesn't show. How can I get it to show itself? 

<telerik:RadGrid ID="ListView_RadGrid" runat="server"
    OnPreRender="ListView_RadGrid_OnPreRender"
    EnableViewState="True"
    GridLines="None"
    TabIndex="5"
    AllowPaging="True"
    AllowSorting="True"
    OnSortCommand="ListView_RadGrid_SortCommand"
    OnDataBound="ListView_RadGrid_DataBound"
    OnDataBinding="ListView_RadGrid_DataBinding"
     
    OnPageIndexChanged="ListView_RadGrid_PageIndexChanged"
    OnNeedDataSource="ListView_RadGrid_OnNeedDataSource"
    OnRowDrop="ListView_RadGrid_OnRowDrop"
    AllowMultiRowSelection="True" 
    ShowDesignTimeSmartTagMessage="True"
    AllowCustomPaging="True"
    OnPageSizeChanged="ListView_RadGrid_PageSizeChanged"
     
>
    <PagerStyle Mode="NextPrevNumericAndAdvanced" Position="TopAndBottom"  ShowPagerText="True" AlwaysVisible="True"   />
 
    <MasterTableView ShowHeader="true" AllowMultiColumnSorting="false" AutoGenerateColumns="False"
        EnableViewState="False" ClientDataKeyNames="ObjectId,Status" DataKeyNames="ObjectId" >
        <CommandItemSettings ExportToPdfText="Export to Pdf"  />
    </MasterTableView>
</telerik:RadGrid>

Jayesh Goyani
Top achievements
Rank 2
 answered on 06 Dec 2012
1 answer
161 views
Unlike a GridTextBoxColumnEditor (which works), the CssClass on the TextBoxStyle for the GridDateTimeColumnEditor doesn't work - the class isn't applied on the "input" box. Can anyone please confirm?

<telerik:GridDateTimeColumn PickerType="DatePicker" DataField="InstallationDate" FilterControlAltText="Filter Install Date" HeaderText="Install Date" SortExpression="InstallationDate" UniqueName="InstallationDate" ReadOnly="false" AllowFiltering="true" MaxLength="50" ColumnEditorID="gceSmallDateBox">
                                    </telerik:GridDateTimeColumn>


<telerik:GridDateTimeColumnEditor runat="server" ID="gceSmallDateBox">
                            <TextBoxStyle CssClass="smallTextBox" />
                        </telerik:GridDateTimeColumnEditor>

Jayesh Goyani
Top achievements
Rank 2
 answered on 06 Dec 2012
6 answers
176 views
We're using a GridAttachmentColumn to upload stuff within a databound Grid.

How can I hide this column in View mode and only display it when an item is in Edit mode? We also use InPlace editing and I suppose we would need to rebind the grid. Possible to hide the column via JavaScript?
Peter
Top achievements
Rank 1
 answered on 06 Dec 2012
2 answers
127 views
Hi,

I use RadWindow throughout my application.
I typically close the window in code behind using winPDF.VisibleOnPageLoad = false; and this works just fine.
However, if I'm using the following code to cause a file to be downloaded to the client, then the RadWindow remains open:

Response.ContentType = "application/pdf";
Response.AppendHeader("Content-Disposition", "attachment; filename=\"" + fullfilename + "\"");
Response.TransmitFile(fullfilename);
 
winPDF.VisibleOnPageLoad = false; // Close the RadWindow

Placing the last line above before the Response. statements has no effect.
I have tried adding  OnClientClicked="closePDF();return false;" to the RadButton on the RadWindow that performs the export, but that results in an error since the function can't seem to find the window.  My idea was to cause the window to close and then the postback to occur to cause the above code behind to fire.  Here's the relevant code in my aspx page:

function closePDF() {
 
                var window = $find("ctl00_ContentPlaceHolder_winPDF");
                window.close();
            }
 
<telerik:RadWindow ID="winPDF" Width="300px" Height="240px" runat="server" Title="Export to PDF" Style="z-index: 999999"
                VisibleOnPageLoad="false" Behaviors="Move" EnableShadow="true" Modal="true" OnClientClose="OnClientClose">
                <ContentTemplate>
                    <div style="padding: 5px;">
                        <telerik:RadButton ID="btnEx2PDF" OnClick="Export2PDF" CommandName="Export" Text="Export" OnClientClicked="closePDF();return false;"
                            runat="server">
                        </telerik:RadButton>
                        <telerik:RadButton ID="btnCancel" OnClick="Export2PDF" CommandName="Cancel" Text="Cancel"
                            CausesValidation="false" runat="server">
                        </telerik:RadButton>
                    </div>
...

When the application is run, the "window" variable in the above function is null.
If I remove the OnClientClicked event from the RadButton, I get no errors, but the RadWindow will not close.

Any ideas?

Thanks in advance

Jim
jlj30
Top achievements
Rank 2
 answered on 05 Dec 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?