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

I have a Grid where I select a row.  When I select a row I want to capture the email address that's displayed in the Grid.  I typically use a SqlDataSource as the data source for my Grids and don't have any trouble getting the value from a cell on a selected row, but this time I had to use a DataTable.  Please help me modify my code so that I may capture the email address from the selected row on the Grid.

 

Here is the Grid markup:

<telerik:RadGrid ID="rgAdUsrs" runat="server" AutoGenerateColumns="false" AllowPaging="true" AllowSorting="true" AllowFilteringByColumn="true" ShowGroupPanel="true" Skin="Office2010Black" OnSelectedIndexChanged="rgAdUsrs_SelectedIndexChanged" GroupingSettings-CaseSensitive="false">
            <ClientSettings AllowDragToGroup="true" AllowColumnsReorder="true" ReorderColumnsOnClient="true"></ClientSettings>
            <MasterTableView>               
                <PagerStyle PageSizes="10, 25, 50, 100, 250, 400" AlwaysVisible="true" />               
                <Columns>
                    <telerik:GridButtonColumn ButtonType="LinkButton" Text="Select" CommandName="Select"></telerik:GridButtonColumn>
                    <telerik:GridBoundColumn DataField="givenName" HeaderText="First Name" SortExpression="givenName" UniqueName="givenName" FilterControlAltText="Filter givenName column" HeaderStyle-Font-Bold="true" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"></telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="sn" HeaderText="Last Name" SortExpression="sn" UniqueName="sn" FilterControlAltText="Filter sn column" HeaderStyle-Font-Bold="true" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"></telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="mail" HeaderText="Email" SortExpression="mail" UniqueName="mail" FilterControlAltText="Filter mail column" HeaderStyle-Font-Bold="true" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"></telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="department" HeaderText="Department" SortExpression="department" UniqueName="department" FilterControlAltText="Filter department column" HeaderStyle-Font-Bold="true" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"></telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="manager" HeaderText="Manager" SortExpression="manager" UniqueName="manager" FilterControlAltText="Filter manager column" HeaderStyle-Font-Bold="true" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"></telerik:GridBoundColumn>                   
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>

 

Here is the code behind for the SelectedIndexChanged event:

protected void rgAdUsrs_SelectedIndexChanged(object sender, EventArgs e)
        {
            foreach (GridDataItem item in rgAdUsrs.SelectedItems)
            {
                repidtxttest.Text = item["mail"].Text;
                hdnRepId.Value = item["mail"].Text;
                hdnRepGivenName.Value = item["givenName"].Text;
                hdnRepSn.Value = item["sn"].Text;
                hdnRepDept.Value = item["department"].Text;
                hdnRepsMgr.Value = item["manager"].Text;
            }
        }

 

Here is the code from the data table:

DataTable dt = new DataTable();
 
            dt.Columns.AddRange(new DataColumn[5]
            {
                new DataColumn("givenName", typeof (string)),
                new DataColumn("sn", typeof (string)),
                new DataColumn("mail", typeof (string)),
                new DataColumn("department", typeof (string)),
                new DataColumn("manager", typeof (string))
            });
 
            using (var context = new PrincipalContext(ContextType.Domain, null))
            {
                using (var group = (GroupPrincipal.FindByIdentity(context, "Group1")))
                {
                    var users = group.GetMembers(true);
                    foreach (UserPrincipal user in users)
                    {
                        DirectoryEntry de = user.GetUnderlyingObject() as DirectoryEntry;
                        dt.Rows.Add
                        (
                            Convert.ToString(de.Properties["givenName"].Value),
                            Convert.ToString(de.Properties["sn"].Value),
                            Convert.ToString(de.Properties["mail"].Value),
                            Convert.ToString(de.Properties["department"].Value),
                            Regex.Replace((Convert.ToString(de.Properties["manager"].Value)), @"CN=([^,]*),.*$", "$1")
                        );
                    }
                    rgAdUsrs.DataSource = dt;
                    rgAdUsrs.DataBind();
                }
            }

 

Eyup
Telerik team
 answered on 05 Sep 2018
7 answers
1.0K+ views
  No matter what i try i cant get the edit/insert form to close when i use forms or popup.

 

//this throws and error : Insert item is available only when grid is in insert mode.
protected void RadGrid1_InsertCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) {   
 
e.Item.OwnerTableView.IsItemInserted = false;   
 
RadGrid1.Rebind();  
 
}  
 
//this had no effect   
 
protected void RadGrid1_InsertCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) {   
 
e.Cancelled = true;  
 
RadGrid1.Rebind();  
 
}  
 
// nothing on edit either   
 
protected void RadGrid1_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgse) {   
 
RadGrid1.MasterTableView.ClearEditItems();   
 
RadGrid1.Rebind();  
 
}  
 

// some additional background info:

I have tried it in forms & popup and with a user control and not

 

 

 

<telerik:RadGrid ID="RadGrid1" runat="server"   
 
GridLines="None"   
 
AllowPaging="True"   
 
PageSize="10"   
 
AllowAutomaticDeletes="True"   
 
AllowAutomaticInserts="True"   
 
AllowAutomaticUpdates="True"   
 
AutoGenerateColumns="False"   
 
OnItemDataBound="RadGrid1_ItemDataBound"   
 
OnInsertCommand="RadGrid1_InsertCommand"   
 
OnUpdateCommand="RadGrid1_UpdateCommand"   
 
OnDeleteCommand="RadGrid1_DeleteCommand"   
 
OnNeedDataSource="RadGrid1_NeedDataSource">   
 
<PagerStyle Mode="NextPrevAndNumeric" />   
 
<MasterTableView Width="950" CommandItemDisplay="TopAndBottom" DataKeyNames="PromoCode" EditMode="EditForms" >   
 
<Columns>   
 
<telerik:GridTemplateColumn>   
 
<ItemTemplate>   
 
<asp:ImageButton ID="Button1" runat="server" ImageUrl="~/App_Themes/Default/Images/EditButton.gif"   
 
Text="Edit" CommandName="Edit" />   
 
</ItemTemplate>   
 
</telerik:GridTemplateColumn>   
 
<telerik:GridTemplateColumn HeaderText="PromoCode" SortExpression="PromoCode" UniqueName="PromoCode">  
 
<ItemTemplate>   
 
<asp:Label runat="server" ID="lblPromoCode" Text='<%# Eval("PromoCode") %>'></asp:Label>   
 
</ItemTemplate>   
 
<EditItemTemplate>   
 
<asp:TextBox runat="server" ID="tbxPromoCode" EnableViewState="true" ></asp:TextBox>   
 
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="tbxPromoCode"   
 
ErrorMessage="*" runat="server">   
 
</asp:RequiredFieldValidator>   
 
</EditItemTemplate>   
 
</telerik:GridTemplateColumn> 
 
<telerik:GridButtonColumn ConfirmText="Delete this Item?" ConfirmDialogType="RadWindow"   
 
ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"   
 
UniqueName="DeleteColumn">   
 
</telerik:GridButtonColumn>   
 
</Columns>   
 
</MasterTableView>   
 
</telerik:RadGrid>   
 
 

 

 Page.Response.Redirect does work but it is not an option. lol

 

Raoul
Top achievements
Rank 1
 answered on 04 Sep 2018
1 answer
312 views

I am having a hard time getting the Legend label values to equal the pie series NameField values.

 

<telerik:RadHtmlChart ID="rhcDiscountReasons" runat="server" DataSourceID="sqlDRRAlt" ChartTitle-Text="Discount Reasons">
<ChartTitle Text="Discount Reasons">
<Appearance Visible="True">
</Appearance>
</ChartTitle>
<Legend>
<Appearance Visible="True" BackgroundColor="WindowFrame" Align="Center" Position="Bottom" Orientation="Horizontal">
    <TextStyle Color="White" FontSize="18" />
</Appearance>
<Item Visual="legendItemVisual" />
</Legend>
  <PlotArea>
                <Series>
                    <telerik:PieSeries DataFieldY="dtypecount" Name="Discount Reasons" VisibleInLegend="true" NameField="dtype">
                        <LabelsAppearance DataField="dtype">
                        </LabelsAppearance>
                    </telerik:PieSeries>
                </Series>
 </PlotArea>
</telerik:RadHtmlChart>

 

If I use the below code, It fills all the legend labels with "Discount Reasons", I want them to have the NameField values.  I have tried everything I could think of to access those values but cannot.  If I replace e.series.name with e.series.categoryField the legend lables all say "dtype", this is close but I want the dtype value.

var label = new drawing.Text(e.series.name, [0, 0], {
        fill: {
            color: legendLabelsColor
        }
    })

Can someone point me in the right direction?

 

 

Vessy
Telerik team
 answered on 04 Sep 2018
3 answers
462 views

Hi,

 

My DevCraft Complete expired on Jan/2018 and I use WPF controls and Reporting Services. I do not want to renew the subscription but my Visual Studio keeps popping up a Subscription Expired Notice! How do I stop that?

 

Thank you.

Rumen
Telerik team
 answered on 04 Sep 2018
3 answers
90 views

Documentation for Telerik UI for ASP.NET AJAX  are not available anymore

https://docs.telerik.com/devtools/aspnet-ajax/introduction

Could you please fix it quiclky.

José

 

 

José
Top achievements
Rank 1
 answered on 04 Sep 2018
3 answers
168 views

Hello

I'd like to be able to change the color of a ScatterSeriesItem point upon clicking. I have tried the following in Javascript; However, it didn't work. I'd appreciate for the help.

 

function seriesClick(e) {

  // change the color of the point to red

   e.point.color = "#ff0000"; 

  // redraw the chart

  var chart = $find("chart").get_kendoWidget();
  chart.redraw();

}

 

In C#, I am able to change a point's color by ScatterSeriesItem.BackgroundColor property, however I need to be able to do it in Javascript.

Thanks.

 

Eyup
Telerik team
 answered on 04 Sep 2018
2 answers
165 views

Hi,

I have a radgrid which contains a template column.  Within the Edit template is a dropdown control.

I have the edit mode to set to batch.  I then have the client method:

<ClientEvents OnBatchEditCellValueChanged="BatchEditCellValueChanged" />

 

This triggers the following method:

function BatchEditCellValueChanged(sender, parameters) {     sender.get_batchEditingManager().saveAllChanges();}

 

The problem I have is that when a user makes a change to the dropdown list the page freezes and then it crashes.

If I remove the template column, the editing works fine.

What do I need to do in order for this to work?

Thanks.

Eyup
Telerik team
 answered on 04 Sep 2018
4 answers
1.3K+ views
hi there,
I have some textboxes (for name, surname etc) and and a radgrid on my web page.(for products for example). all radgrid's rows are in "inplace" edit mode.. When I press to external button, form postbacks. meanwhile All information user entered in ragrid get lost. I think I have to update radgrid first but I don't know how ? because there's no update command column in grid. all rows in edit mode and while postingback I need to update all of them at once. How can achieve this ?
best



    Protected Sub radGridProducts_NeedDataSource(sender As Object, e As GridNeedDataSourceEventArgs) Handles radGridProducts.NeedDataSource
        Dim dt As New DataTable
        dt = DirectCast(Session("RequestMonetDataTable"), DataTable)
        radGridProducts.DataSource = dt
    End Sub
 
    Protected Sub radGridProducts_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles radGridProducts.PreRender
        If Not IsPostBack Then
            For Each item As GridItem In radGridProducts.MasterTableView.Items
                If TypeOf item Is GridEditableItem Then
                    Dim editableItem As GridEditableItem = CType(item, GridDataItem)
                    editableItem.Edit = True
                End If
            Next
            radGridProducts.Rebind()
        End If
    End Sub
 
    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        If IsPostBack = False Then
            CreateDataSource()
   end If
 
    Protected Sub CreateDataSource()
        Dim dt As New DataTable
        Dim dr As DataRow
 
        dt.Columns.Add(New Data.DataColumn("ID", GetType(String)))
        dt.Columns.Add(New Data.DataColumn("product", GetType(String)))
        dt.Columns.Add(New Data.DataColumn("quantity", GetType(Integer)))
        dt.Columns.Add(New Data.DataColumn("price", GetType(Decimal)))
 
 
        dr = dt.NewRow
        dr("ID") = 1
        dr("product") = "aaa"
        dr("quantity") = 0
        dr("price") = 0
        dt.Rows.Add(dr)
       
        ' here I add some more rows.....
 
        Session("RequestMonetDataTable") = dt
  
    End Sub
Marin Bratanov
Telerik team
 answered on 03 Sep 2018
11 answers
466 views
Hi,

When using the pie chart I get very small indicators on the legend - the following code has my database driven pie chart on top and a modified version of the sample below it.  The bottom chart shows little square blocks to the left of the legend.  The database driven chart on the top shows tiny blocks - you may need to zoom to see them....

I assume this is a bug?

Regards

Jon

<telerik:RadHtmlChart runat="server" ID="RadHtmlChart2" Width="765px" Height="135px" Transitions="true" Skin="Forest" DataSourceID="SqlDataSource1" >
    <PlotArea >
        <Series>
            <telerik:PieSeries DataFieldY="TaskCount" NameField="TaskType" ></telerik:PieSeries>
        </Series>
    </PlotArea>
</telerik:RadHtmlChart>         
         
<telerik:RadHtmlChart runat="server" ID="RadHtmlChart1" Width="765px" Height="135px" Transitions="true" Skin="Forest" >
    <PlotArea >
        <Series>
            <telerik:PieSeries  >
                <Items>
                    <telerik:SeriesItem BackgroundColor="#ff9900" Exploded="true" Name="Internet Explorer" YValue="18.3"></telerik:SeriesItem>
                    <telerik:SeriesItem BackgroundColor="#cccccc" Exploded="false" Name="Firefox" YValue="35.8"></telerik:SeriesItem>
                    <telerik:SeriesItem BackgroundColor="#999999" Exploded="false" Name="Chrome" YValue="38.3"></telerik:SeriesItem>
                    <telerik:SeriesItem BackgroundColor="#666666" Exploded="false" Name="Safari" YValue="4.5"></telerik:SeriesItem>
                    <telerik:SeriesItem BackgroundColor="#333333" Exploded="false" Name="Opera" YValue="2.3"></telerik:SeriesItem>
                </Items>
            </telerik:PieSeries>
        </Series>
    </PlotArea>
</telerik:RadHtmlChart>
Vessy
Telerik team
 answered on 03 Sep 2018
3 answers
323 views

I have radgrid with some data and timer, I want to move next page automatically in radgrid every 5 second and then back to first page when meet the last page.

How do I set this radgrid automatically move next page?

Below is my aspx page:

ASPX:
 </telerik:RadAjaxLoadingPanel> <asp:Timer ID="Timer1" runat="server"  Interval="5000">
 </asp:Timer>     

<telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="-1" DataSourceID="SqlDataSource1" GridLines="Both"     GroupPanelPosition="Top"  Skin="BlackMetroTouch"  Width="100%" Height="800px"  AllowPaging="True" >
        <MasterTableView AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
            <Columns>
                <telerik:GridBoundColumn DataField="ID_Mesin" FilterControlAltText="Filter ID_Mesin column" HeaderText="ID_Mesin" SortExpression="ID_Mesin" UniqueName="ID_Mesin">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Tanggal_Laporan" DataType="System.DateTime" FilterControlAltText="Filter Tanggal_Laporan column" HeaderText="Tanggal_Laporan" SortExpression="Tanggal_Laporan" UniqueName="Tanggal_Laporan">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Lokasi" FilterControlAltText="Filter Lokasi column" HeaderText="Lokasi" SortExpression="Lokasi" UniqueName="Lokasi">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Pelapor" FilterControlAltText="Filter Pelapor column" HeaderText="Pelapor" SortExpression="Pelapor" UniqueName="Pelapor">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Keterangan_Pelapor" FilterControlAltText="Filter Keterangan_Pelapor column" HeaderText="Keterangan_Pelapor" SortExpression="Keterangan_Pelapor" UniqueName="Keterangan_Pelapor">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Tanggal_Diterima" DataType="System.DateTime" FilterControlAltText="Filter Tanggal_Diterima column" HeaderText="Tanggal_Diterima" SortExpression="Tanggal_Diterima" UniqueName="Tanggal_Diterima">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Nama_Penerima" FilterControlAltText="Filter Nama_Penerima column" HeaderText="Nama_Penerima" SortExpression="Nama_Penerima" UniqueName="Nama_Penerima">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Keterangan_Penerima" FilterControlAltText="Filter Keterangan_Penerima column" HeaderText="Keterangan_Penerima" SortExpression="Keterangan_Penerima" UniqueName="Keterangan_Penerima">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Tanggal_Selesai" DataType="System.DateTime" FilterControlAltText="Filter Tanggal_Selesai column" HeaderText="Tanggal_Selesai" SortExpression="Tanggal_Selesai" UniqueName="Tanggal_Selesai">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Mesin_Stop" FilterControlAltText="Filter Mesin_Stop column" HeaderText="Mesin_Stop" SortExpression="Mesin_Stop" UniqueName="Mesin_Stop">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Tindakan" FilterControlAltText="Filter Tindakan column" HeaderText="Tindakan" SortExpression="Tindakan" UniqueName="Tindakan">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Status" FilterControlAltText="Filter Tindakan column" HeaderText="Status" SortExpression="Status" UniqueName="Status">
                </telerik:GridBoundColumn>
            </Columns>
        </MasterTableView>
        <ClientSettings>
            <Scrolling AllowScroll="True" UseStaticHeaders="true" />
        </ClientSettings>
 </telerik:RadGrid>
 <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ePMPConnectionString %>" SelectCommand="SELECT * FROM [DetailProblem]"></asp:SqlDataSource>

Eyup
Telerik team
 answered on 03 Sep 2018
Narrow your results
Selected tags
Tags
+? more
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?