Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
112 views
Hello there,
                   My requirement is that each row in radgrid, has a textbox and a dropdownlist inside the item template. When a  value is selected in the dropdownlist, it should populate the textbox with the selected value.
                  I tried using the dropdownlist_SelectedIndexChanged, it does populates the textbox but as not expected.For exmaple, if the radgrid contains 3 rows, ifi  i select a value in the dropdownlist at row 1, it populates the textbox at row 1 and also the textbox on other rows with the corresponding selected value of the dropdownlist in that row. I just want the action to take place in the particular row, and not in all the rows.
                 I also tried using  the client side function and made the Autopostback=false. But it doesn't work as well. $find("<%= rgUserAttendance.ClientID %>"); -->always returns null.
                 Any help on this would be much appreciated.

.ascx
--------
<script type="text/javascript" >

 function OnSelectedIndexChange(rowindex,radGridClientID)
    {
         var grid = $find("<%= rgUserAttendance.ClientID %>");
         if(grid)
       {
            alert('grid found');
            var MasterTable = grid.get_masterTableView();
       }
       else 
       {
            alert('grid not found');
       } 
      
      var row = MasterTable.get_dataItems()[rowindex];
    }
</script>
<table width="900px" align="left">
<tr id="trGrid" runat="server" visible="true">
        <td class="bodyCopy">
            <radG:RadGrid ID="rgUserAttendance" runat="server" OnItemDataBound="rgUserAttendance_ItemDataBound"
                Skin="Inox" GridLines="None" AutoGenerateColumns="False" Width="100%" UseEmbeddedScripts="False">
                <MasterTableView DataKeyNames="EM_ID,EM_moduleID">
                    <Columns>
                        <radG:GridBoundColumn DataField="MDL_Code" HeaderText="Code" UniqueName="MDL_Code">
                            <ItemStyle VerticalAlign="Top" />
                        </radG:GridBoundColumn>
                        <radG:GridBoundColumn DataField="MDL_Name" HeaderText="Module" UniqueName="MDL_Name">
                            <ItemStyle VerticalAlign="Top" />
                        </radG:GridBoundColumn>
                        <radG:GridBoundColumn DataField="storeName" HeaderText="Store" UniqueName="storeName">
                            <ItemStyle VerticalAlign="Top" />
                        </radG:GridBoundColumn>
                        <radG:GridTemplateColumn UniqueName="AttendedColumn" HeaderText="Attended">
                            <ItemTemplate>
                                <asp:CheckBox ID="chkAttended" runat="server" Checked='<%# Eval("EM_isAttended") %>' />
                            </ItemTemplate>
                            <ItemStyle VerticalAlign="Top" />
                        </radG:GridTemplateColumn>
                        <radG:GridTemplateColumn HeaderText="Competent" UniqueName="TemplateColumn">
                            <ItemStyle HorizontalAlign="Center" VerticalAlign="Top" Width="100px" />
                            <ItemTemplate>
                                <asp:CheckBox ID="chkCompetent" runat="server" Checked='<%# Eval("EM_isCompetent") %>' />
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox runat="server"></asp:TextBox>
                            </EditItemTemplate>
                        </radG:GridTemplateColumn>
                        <radG:GridTemplateColumn UniqueName="RPLColumn" HeaderText="RPL">
                            <ItemTemplate>
                                <asp:CheckBox ID="chkRPLColumn" runat="server" />
                            </ItemTemplate>
                            <ItemStyle VerticalAlign="Top" />
                        </radG:GridTemplateColumn>
                        <radG:GridTemplateColumn UniqueName="ScoreColumn" HeaderText="Pass %">
                            <ItemTemplate>
                                <asp:TextBox ID="txtScore" runat="server" Width="35px" CssClass="bodyCopy" Text='<%# Eval("EM_score") %>' />
                                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" CssClass="bodyCopy"
                                    ControlToValidate="txtScore" ErrorMessage=" * Not valid" ValidationExpression="^\d+(\.\d{1,2})?$" />
                            </ItemTemplate>
                            <ItemStyle VerticalAlign="Top" />
                        </radG:GridTemplateColumn>
                        <radG:GridTemplateColumn UniqueName="UserFeedbackColumn" HeaderText="User Feedback"
                            Visible="False">
                            <ItemTemplate>
                                <asp:TextBox ID="txtUserFeedback" runat="server" Columns="30" Rows="3" TextMode="MultiLine"
                                    CssClass="bodyCopy" Text='<%# Eval("EM_userFeedback") %>' />
                            </ItemTemplate>
                        </radG:GridTemplateColumn>
                        <radG:GridTemplateColumn UniqueName="TrainerFeedbackColumn" HeaderText="Trainer Comments">
                            <ItemTemplate>
                                <asp:TextBox ID="txtTrainerFeedback" runat="server" Columns="30" Rows="3" TextMode="MultiLine"
                                    CssClass="bodyCopy" />
                            </ItemTemplate>
                        </radG:GridTemplateColumn>
                        <radG:GridTemplateColumn UniqueName="CommentColumn" HeaderText="Select Comments">
                            <ItemTemplate>
                                <asp:DropDownList ID="ddlComment" runat="server" AutoPostBack="false" />
                               <!-- <asp:DropDownList ID="ddlComment" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlComment_SelectedIndexChanged"  /> -->
                            </ItemTemplate>
                        </radG:GridTemplateColumn>
                        <radG:GridTemplateColumn UniqueName="TestColumn" HeaderText="Test Comments">
                            <ItemTemplate>
                                <radCom:RadComboBox ID="rcbComment" runat="server" AutoPostBack="false" OnClientSelectedIndexChanged="rcbComment_SelectedIndexChanged">
                                    <Items>
                                        <radCom:RadComboBoxItem Text="1" Value="1" />
                                        <radCom:RadComboBoxItem Text="2" Value="2" />
                                        <radCom:RadComboBoxItem Text="3" Value="3" />
                                    </Items>
                                </radCom:RadComboBox>
                            </ItemTemplate>
                        </radG:GridTemplateColumn>
                    </Columns>
                    <HeaderStyle Font-Bold="True" CssClass="shutter" HorizontalAlign="Left" />
                    <ExpandCollapseColumn Visible="False">
                        <HeaderStyle Width="19px" />
                    </ExpandCollapseColumn>
                    <RowIndicatorColumn Visible="False">
                        <HeaderStyle Width="20px" />
                    </RowIndicatorColumn>
                </MasterTableView>
                <ClientSettings AllowColumnHide="True" >
                    <ClientEvents OnGridCreated="GetGridObject"></ClientEvents>
                </ClientSettings>
            </radG:RadGrid>
        </td>
    </tr>
</table>

ascx.cs
-----------
  protected void rgUserAttendance_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = (GridDataItem)e.Item;
            DropDownList ddl = item.FindControl("ddlComment") as DropDownList;
     Hashtable hshComment = new Hashtable();
            hshComment.Add("0", "--Select Comment--");
            hshComment.Add("1", "Comment 1");
            hshComment.Add("2", "Comment 2");
            hshComment.Add("3", "Comment 3");

            //populating the dropdownlist
            foreach (DictionaryEntry entry in hshComment)
            {
                ListItem itemComment = new ListItem();
                itemComment.Text = entry.Value.ToString();
                itemComment.Value = entry.Key.ToString();

                ddl.Items.Add(itemComment);

            }
            ddl.Attributes.Add("onChange", "OnSelectedIndexChange('" + item.ItemIndex + "','" + this.rgUserAttendance.ClientID + "' );");
          }
    }

 public void ddlComment_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownList dropdownlist1 = (DropDownList)sender;
        GridDataItem item = (GridDataItem)dropdownlist1.NamingContainer;

        TextBox txtTrainerFeedback = (TextBox)item.FindControl("txtTrainerFeedback");


        switch (Convert.ToInt32(dropdownlist1.SelectedValue))
        {
            case 1:
                txtTrainerFeedback.Text += " " + FrameWorkSettings.SessionAttendanceComment1;
                break;
            case 2:
                txtTrainerFeedback.Text += " " + FrameWorkSettings.SessionAttendanceComment2;
                break;
            case 3:
                txtTrainerFeedback.Text += " " + FrameWorkSettings.SessionAttendanceComment3;
                break;
            default:
                txtTrainerFeedback.Text += " ";
                break;
        }
    }

 














Shinu
Top achievements
Rank 2
 answered on 06 Mar 2014
4 answers
140 views
Hi,

Here is the skeleton of my aspx page in which I am trying to add  a pageview from client side. The JS shows no error but the code is not working as expected. Please let me know whats the mistake in the code.

<telerik:RadTabStrip ID="RadTabStripBoard" runat="server" MultiPageID="RadMultiPage1">
   <Tabs>
       <telerik:RadTab runat="server" Text="Gifts">
       </telerik:RadTab>
       <telerik:RadTab runat="server" Text="Coupons">
       </telerik:RadTab>
   </Tabs>
</telerik:RadTabStrip>   
<telerik:RadMultiPage ID="RadMultiPage1" runat="server">           
</telerik:RadMultiPage>
<telerik:RadButton ID="Add" runat="server" OnClientClicked="AddTab">
</telerik:RadButton>
<script>
   function AddTab(sender, args)
   {           
       var multiPage1 = $find("<%=RadMultiPage1.ClientID %>");                       
       var pageView = new Telerik.Web.UI.RadPageView();     
       multiPage1.get_pageViews().add(pageView);          
   
</script>
Olivier
Top achievements
Rank 2
 answered on 06 Mar 2014
2 answers
119 views
Hi,

i have a.aspx, in this page has radwindow(without NavigateUrl) with content template and content template has some controls like this.

<telerik:RadWindowManager ID="RadWindowManager1" runat="server" Overlay="true">
        <Windows>
            <telerik:RadWindow ID="rwtahsilat" runat="server" VisibleOnPageLoad="false" Height="580px" OnClientClose="OnClientClose"
                        Width="870px" Modal="true" VisibleStatusbar="False" Behaviors="Close" Skin="Metro">
                    <Localization Close="Kapat" Cancel="Vazgeç" No="Hayır" OK="Tamam" Yes="Evet" />
                    <ContentTemplate>
                        Seri No : <asp:Label ID="lbl_terminal_seri_no" runat="server" Text=""></asp:Label>
                        Tarih : <asp:Label ID="lbl_tarih" runat="server" Text=""></asp:Label>
                        Tahsilat Tutar : <telerik:RadNumericTextBox CssClass="tbxa100aa" ID="rnt_tahsilat_tutar"
                                runat="server" Width="100px"></telerik:RadNumericTextBox> TL
                        <asp:Button ID="bt_tahsilat_isle" runat="server" Text="KAYDET" CssClass="btTuruncu5"  />
                        <asp:Label ID="sonuc" CssClass="sonuc" runat="server"></asp:Label>
                    </ContentTemplate>
                </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>

radwindow has not navigate url. when i click button ID=bt_tahsilat_isle, a.aspx is postback then radwindow closing and button process all code then radwindow show again.

i want to do when i click button ID=bt_tahsilat_isle not close radwindow (like radwindow has navigate url)
Hüseyin
Top achievements
Rank 1
 answered on 06 Mar 2014
5 answers
497 views
I have a simple RadGrid:

<telerik:RadGrid ID="rgHeaderKey" runat="server">
  <HeaderStyle Font-Bold="true" />
  <MasterTableView HeaderStyle-HorizontalAlign="Center" HeaderStyle-Font-Bold="true" />
</telerik:RadGrid>

The columns and rows are bound to a table in a database; yet some of the columns do not contain any data (that is, all the entries in that column are NULL).  I need to hide those columns that do not contain any data after the grid has been filled.  I tried the following handler for the OnDataBound event:

protected void GridHeaderKeyDataBound(object sender, EventArgs e)
{
    // after data-binding, hide any columns that have no entries
    for(int i = 0; i < rgHeaderKey.Columns.Count; i++)
    {
        // check the entry in the first row
        GridColumn col = rgHeaderKey.Columns[i];
        if (String.IsNullOrEmpty(rgHeaderKey.Items[0][col].Text)) col.Display = false;
    }
}

This fails, however, because rgHeaderKey.Columns.Count is always 0, even after the data have been bound (which I find a bit strange).  I realise this might be because the columns are automatically generated: however, I need it this way because I do not know the names of the columns in advance.

Any help would be very much appreciated.
pierre-jean
Top achievements
Rank 1
Veteran
Iron
 answered on 06 Mar 2014
2 answers
182 views
Hi
I have a RadComboBox with a radTree in it.
I have get text and value of tree node from DataBase. Now i want to select item of radTree that equal to value by JavaScript.
How can i do it?

Here is definition of RadComboBox:

<telerik:RadComboBox runat="server" ID="cmb" EnableVirtualScrolling="true"
    Height="140px" ShowToggleImage="True" Style="vertical-align: middle;" Width="100%"
    OnClientDropDownOpened="cmb_ClientOpened">
    <ItemTemplate>
        <telerik:RadTreeView ID="tv" runat="server" OnClientNodeClicking="tv_ClientNodeClicking">
        </telerik:RadTreeView>
    </ItemTemplate>
    <Items>
        <telerik:RadComboBoxItem Text="" />
    </Items>
</telerik:RadComboBox>
kia
Top achievements
Rank 1
 answered on 06 Mar 2014
7 answers
191 views
Hey there,

I am working on a form using rad controls.I need to make a grid in which first column contains a dropdown,and on its selectedItemIndexChanged I want to show the price of the selected item in the next column on a label.What's the procedure?..
Should i use GridItemTemplate?..Is there any Grid demo which shows a dropDopwn column?..

Need Some help...
Thanks
Amit.
Princy
Top achievements
Rank 2
 answered on 06 Mar 2014
2 answers
266 views
Hi There, I've got a problem with a simple form with button postback, it gives me the following issue, however, if I refresh the page cup of times it seems to be gone away.

Also if I open fiddler, the problem gone away too, very strange.

Any suggestions?


Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E)
Timestamp: Fri, 28 Feb 2014 10:28:25 UTC


Message: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
Details: Error parsing near '

<!DOCTYPE html P'.
Line: 6
Char: 84171
Code: 0
URI: http://cvc98sweb20.mcc.local/FSMSDEV/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=RadScriptManager1_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bSystem.Web.Extensions%2c+Version%3d4.0.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aen-US%3a33363de7-7c08-435e-ab35-682b2ed2c688%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%2c+Version%3d2013.3.1324.40%2c+Culture%3dneutral%2c+PublicKeyToken%3d121fae78165ba3d4%3aen-US%3a597c6a37-3447-4509-ba46-0faaa25cf6f9%3a16e4e7cd%3aed16cbdc%3af7645509%3a88144a7a%3a24ee1bba%3af46195d3%3a874f8ea2%3a19620875%3acda80b3
Leon
Top achievements
Rank 1
 answered on 05 Mar 2014
2 answers
611 views
Hi All,

I want to add the a custom item to context menu on radgrid header context menu like "Default settings \ Clear settings"
and on click of this event in want to fire a server side code which i have .

Could any one help me on this , how can we achieve this , with a small piece of sample code

Thanks
Chaitanya
Top achievements
Rank 1
 answered on 05 Mar 2014
15 answers
180 views
I have a web page with a RadNumericTextBox on it
it needs to implement the following functionality
if the user types in a number it  waits for the user to click a button to fill a grid
if the user increments the box using the mouse wheel or arrow keys it fills a grid with the value of the textbox as a parameter

please advise
moegal
Top achievements
Rank 1
 answered on 05 Mar 2014
1 answer
115 views
Hi

I am using Rad Scheduler Month view and i am getting two problem.First problem is when i click on any date it should be highlight and second when i click on cell ,value of selected cell to be show on aspx page label or any control.

Please help me on this issue .I am using asp.net and c#.
Boyan Dimitrov
Telerik team
 answered on 05 Mar 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?