Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
65 views
Is this possible? Is there a way to have the editor produce ID attributes on all tags using maybe a random number?

<p id="1232"> <table id"2432"></table></p>

Problem I'm having is I need to allow the user to create a hyperlink that is just a bookmark to another part of the document, I need ID's on the tag so that later I can reference where the hyperlink was supposed to point too.
Fred
Top achievements
Rank 1
 answered on 16 Oct 2008
5 answers
196 views
Wondering how I can generate multi layerd sub menu items from data.  I have managed to get the first level sub menu to generate from the initial parent, but how can I generate children of the sub menu items?  I am using vb and this is the current code I have:

'Where To Stay

parentItem = radMenu.Items(1)

For Each row As DataRow In dt.Rows

childItem =

New RadMenuItem

childItem.Text = row(

"Name").ToString

childItem.NavigateUrl =

"~/AtlanticPortal/en/WhereToStay.aspx?Region=" & row("ID").ToString & "&Community=0&Category=0&ProvID=" & Session("ProvID").ToString & "&RegionName=" & row("Name").ToString

parentItem.Items.Add(childItem)

Next

I can get the sum benus to generate in relation to any of the 9 main menu items (parentItem = radMenu.Items(1)), but the sub menu items do not follow the same numbering...  I need the menu items to be generated from a data source as children of a child of menu item1 if that makes any sense.

Dave Navarro
Top achievements
Rank 2
 answered on 16 Oct 2008
1 answer
131 views
I have a user control (header) with a RadMenu in it, which also requires a RadScriptManager.  When I drop the header control on any page that has a RadAjaxManager on it, Ajax stops working.  If I remove the header control and drop a RadScriptManager on the page, Ajax works again.  Is there a setting that I can use to have them all work togather? 

Thanks,
Doug

 

 
Doug
Top achievements
Rank 1
 answered on 16 Oct 2008
3 answers
158 views
I found the post of where you set the node.checked to that of a parent when loading on demand. I have a treeview with the first level being a sport season (2008 Football), next level the leagues, next level, the teams and the final level, the players. When I 'check' the season and then manually expand the tree, the children get loaded and they are automatically 'checked'. I have a couple of problems from there:
1. What if I don't manually expand the tree. the children are not loaded and therefore my functionality of sending emails out will not work. how do i get the children loaded when i just 'check' the parent?
2. the other problem i noticed is if i do expand and then 'uncheck' say a league, the teams and the players underneath that are still 'checked'. how do i get the children to automatically 'uncheck' when i 'uncheck' a parent.

thanks so much.
susan
Simon
Telerik team
 answered on 16 Oct 2008
2 answers
198 views
I have a problem with saving data. I have a tabstrip that is set to AutoPostBack and a Multipage set to RenderSelectedPageOnly.
I have a datalist on the first tab, and a datalist on the second tab.
When I  "Save" the data, I iterate through the first datalist (each item in the list) which is always rendered because it is on the first tab, then I iterate through each item in the second datalist which is on the second tab.
The problem is that if the user has not clicked on the second tab, the second datalist is not fully rendered somehow, so no items are collected and saved.
There is a little more detail. Obviously, if the user clicks on the second tab for the very first time, all the data is saved. It is only when the user opens the page again to edit, and never clicks on the second tab.
What I need to know is:
What is the best way to tell if the datalist on the second tab has been fully rendered? Or do I have to keep up with what tabs are clicked? I had rather just skip the routine to save the data on the second datalist if I could only tell if it was not there or rendered fully.
Thanks,
~bg
GDPR_erased
Top achievements
Rank 1
 answered on 16 Oct 2008
4 answers
104 views
I created the following function for my grid that runs on the PreRender event

    Protected Sub RadGrid1_PreRender(ByVal sender As Object, ByVal e As EventArgs) 
        queueFilter = Request.QueryString("queue") 
        For Each item As GridDataItem In RadGrid1.MasterTableView.Items 
            Dim TaskID As String = item("TaskID").Text 
            If TaskID = "&nbsp;" Then 
                Dim cell As TableCell = item.Item("ExpandColumn") 
                Dim expandCollapseButton As Button = CType(cell.Controls(0), Button) 
                expandCollapseButton.Visible = False 
            ElseIf queueFilter = "My Requests" Then 
                item.Expanded = True 
            End If 
        Next 
    End Sub 

however, this causes a problem when I use the export to Excel feature as I believe it tried to run this code when doing the export.

Is there a way to make sure this code is NOT run during export? I'm looking for something like an IfIsExporting then don't run it, else run it feature. Thanks.
Philip Senechal
Top achievements
Rank 1
 answered on 16 Oct 2008
5 answers
353 views
I have a hierarchial grid that will have 3 levels to it.  I want to keep this example as simple as possible so let's say the grid has 2 visible columns on the first 2 levels - a number column and button column.  The 3rd level has only a number column.  If the button is pushed on the 1st or 2nd level, the number column should be set to zero and all related child rows in the hierarchy below should be set to zero.  All rows updated should have the background set to a color, red for the sake of argument.

How can this be accomplished with VB.Net code?

Here's some starter code.  More columns will be visible than the 2, but just ignore them.

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Grid.aspx.vb" Inherits="Grid" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server">  
    <title>Untitled Page</title> 
    <style type="text/css">  
 
        .ZeroedOut  
        {  
            background-color:pink;  
        }  
 
    </style> 
 
</head> 
<body> 
    <form id="form1" runat="server">  
    <div> 
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">  
        </telerik:RadScriptManager> 
        <telerik:RadGrid ID="grdOR" runat="server" AutoGenerateColumns="False" GridLines="None" Width="100%" Skin="WebBlue"  > 
            <MasterTableView DataKeyNames="STYL_SEQ_NUM,RVD_QTY" AllowAutomaticUpdates="True" NoDetailRecordsText="No SKU records to display." NoMasterRecordsText="No Style records to display." EditMode="InPlace">  
                <DetailTables> 
                    <telerik:GridTableView runat="server" DataKeyNames="MSC_MDSE_NUM" NoDetailRecordsText="No Store records to display." > 
                        <RowIndicatorColumn> 
                            <HeaderStyle Width="20px" /> 
                        </RowIndicatorColumn> 
                        <ExpandCollapseColumn Visible="True">  
                            <HeaderStyle Width="20px" /> 
                        </ExpandCollapseColumn> 
                        <Columns> 
                            <telerik:GridBoundColumn DataField="CLR_CDE" HeaderText="Color Code" UniqueName="CLR_CDE" > 
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn DataField="CLR_DCD" HeaderText="Color Desc" UniqueName="CLR_DCD" > 
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn DataField="STYL_SEQ_NUM" HeaderText="SSN" UniqueName="STYL_SEQ_NUM" > 
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn DataField="MSC_MDSE_NUM" HeaderText="MSC" UniqueName="MSC_MDSE_NUM" > 
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn DataField="RVD_QTY" HeaderText="RVD_QTY" UniqueName="RVD_QTY" ItemStyle-Width="50px" HeaderStyle-Width="50px">  
                            </telerik:GridBoundColumn> 
                            <telerik:GridButtonColumn ButtonType="PushButton" Text="Zero" UniqueName="ZERO" CommandName="ZEROSKU" ItemStyle-Width="50px" HeaderStyle-Width="50px">  
                            </telerik:GridButtonColumn> 
                        </Columns> 
                        <DetailTables> 
                            <telerik:GridTableView runat="server" DataKeyNames="STOR_CDE,MSC_MDSE_NUM,RVD_QTY" EditMode="InPlace" AllowAutomaticUpdates="True" Width="100%" > 
                                <RowIndicatorColumn> 
                                    <HeaderStyle Width="20px" /> 
                                </RowIndicatorColumn> 
                                <ExpandCollapseColumn> 
                                    <HeaderStyle Width="20px" /> 
                                </ExpandCollapseColumn> 
                                <Columns> 
                                    <telerik:GridEditCommandColumn /> 
                                    <telerik:GridTemplateColumn DataField="STOR_CDE" HeaderText="Store" UniqueName="STOR_CDE" > 
                                        <ItemTemplate> 
                                            <%#Eval("STOR_CDE")%> 
                                        </ItemTemplate> 
                                        <EditItemTemplate> 
                                            <asp:TextBox ID="txtStore" runat="server" Text='<%# Bind("STOR_CDE") %>' ReadOnly='<%# IIf(DataBinder.Eval(Container, "OwnerTableView.IsItemInserted"), "False", "True") %>'/>  
                                        </EditItemTemplate> 
                                    </telerik:GridTemplateColumn> 
                                    <telerik:GridTemplateColumn DataField="ORDR_QTY" HeaderText="Quantity" UniqueName="ORDR_QTY">  
                                        <ItemTemplate> 
                                            <%#Eval("ORDR_QTY")%> 
                                        </ItemTemplate> 
                                        <EditItemTemplate> 
                                            <asp:TextBox ID="txtOrderQty" runat="server" Text='<%# Bind("ORDR_QTY") %>' ReadOnly='<%# IIf(DataBinder.Eval(Container, "OwnerTableView.IsItemInserted"), "False", "True") %>' /> 
                                        </EditItemTemplate> 
                                    </telerik:GridTemplateColumn> 
                                    <telerik:GridTemplateColumn DataField="MSC_MDSE_NUM" HeaderText="MSC" UniqueName="MSC_MDSE_NUM">  
                                        <ItemTemplate> 
                                            <%#Eval("MSC_MDSE_NUM")%> 
                                        </ItemTemplate> 
                                        <EditItemTemplate> 
                                            <%# Eval("MSC_MDSE_NUM") %> 
                                        </EditItemTemplate> 
                                    </telerik:GridTemplateColumn> 
                                    <telerik:GridTemplateColumn DataField="RVD_QTY" HeaderText="RVD_QTY" UniqueName="RVD_QTY" ItemStyle-Width="110px" HeaderStyle-Width="110px">  
                                        <ItemTemplate> 
                                            <%#Eval("RVD_QTY")%> 
                                        </ItemTemplate> 
                                        <EditItemTemplate> 
                                            <asp:TextBox ID="txtRevisedQuantity" runat="server" Text='<%# Bind("RVD_QTY") %>' /> 
                                        </EditItemTemplate> 
                                    </telerik:GridTemplateColumn> 
                                </Columns> 
                                <EditFormSettings> 
                                    <EditColumn UniqueName="EditCommandColumn1">  
                                    </EditColumn> 
                                </EditFormSettings> 
                            </telerik:GridTableView> 
                        </DetailTables>                         
                    </telerik:GridTableView> 
                </DetailTables> 
                <RowIndicatorColumn> 
                    <HeaderStyle Width="20px" /> 
                </RowIndicatorColumn> 
                <ExpandCollapseColumn Visible="True">  
                    <HeaderStyle Width="20px" /> 
                </ExpandCollapseColumn> 
                <Columns> 
                    <telerik:GridBoundColumn DataField="ITEM_DES" HeaderText="Desc" UniqueName="ITEM_DES">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="VEN_STYL_NUM" HeaderText="Style" UniqueName="VEN_STYL_NUM">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="STYL_SEQ_NUM" HeaderText="SSN" UniqueName="STYL_SEQ_NUM">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridTemplateColumn DataField="RVD_QTY" HeaderText="RVD_QTY" UniqueName="RVD_QTY" ItemStyle-Width="50px" HeaderStyle-Width="50px">  
                        <ItemTemplate> 
                            <%#Eval("RVD_QTY")%> 
                        </ItemTemplate> 
                        <EditItemTemplate> 
                            <asp:TextBox ID="txtRevisedStyle" runat="server" Text='<%# Bind("RVD_QTY") %>' /> 
                        </EditItemTemplate> 
                    </telerik:GridTemplateColumn> 
                    <telerik:GridButtonColumn ButtonType="PushButton" Text="Zero" UniqueName="ZERO" CommandName="ZEROSTYLE" ItemStyle-Width="50px" HeaderStyle-Width="50px">  
                    </telerik:GridButtonColumn> 
                </Columns> 
                <EditFormSettings > 
                    <PopUpSettings Modal="True" /> 
                </EditFormSettings> 
            </MasterTableView> 
            <ClientSettings> 
                <Scrolling AllowScroll="True" UseStaticHeaders="True" /> 
            </ClientSettings> 
        </telerik:RadGrid> 
      
    </div> 
    </form> 
</body> 
</html> 
 

Imports System.Data  
Imports Telerik.Web.UI  
 
Partial Class Grid  
 
    Inherits System.Web.UI.Page  
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load  
 
    End Sub  
 
    Protected Sub grdOR_DetailTableDataBind(ByVal source As Object, ByVal e As Telerik.Web.UI.GridDetailTableDataBindEventArgs) Handles grdOR.DetailTableDataBind  
 
        Dim parentItem As GridDataItem = CType(e.DetailTableView.ParentItem, GridDataItem)  
 
        If parentItem.Edit Then  
            Return  
        End If  
 
        Dim DataKeys() As String = parentItem.KeyValues.Split(",")  
 
        If e.DetailTableView.HierarchyIndex = "0" Then  
 
            If ViewState(e.DetailTableView.ClientID) Is Nothing Then  
 
                Dim Keys() As String = DataKeys(0).Split(":")  
                e.DetailTableView.DataSource = PopulateSKULevel(Keys(1).Replace("""", "").Replace("}", ""))  
                ee.DetailTableView.Name = e.DetailTableView.ClientID  
                ViewState(e.DetailTableView.ClientID) = e.DetailTableView.DataSource  
 
            Else  
 
                e.DetailTableView.DataSource = ViewState(e.DetailTableView.ClientID)  
 
            End If  
 
        ElseIf e.DetailTableView.HierarchyIndex.Substring(0, 2) = "0_" Then  
 
            If ViewState(e.DetailTableView.ClientID) Is Nothing Then  
 
                Dim Keys() As String = DataKeys(0).Split(":")  
                e.DetailTableView.DataSource = PopulateStoreLevel(Keys(1).Replace("""", "").Replace("}", ""))  
                ee.DetailTableView.Name = e.DetailTableView.ClientID  
                ViewState(e.DetailTableView.ClientID) = e.DetailTableView.DataSource  
 
            Else  
 
                e.DetailTableView.DataSource = ViewState(e.DetailTableView.ClientID)  
 
                If ViewState("grdOR_Event") = "STOREUPDATED" Then  
 
                    Dim parentSKU As GridDataItem = CType(e.DetailTableView.ParentItem, GridDataItem)  
                    Dim parentStyle As GridDataItem = CType(parentSKU.OwnerTableView.ParentItem, GridDataItem)  
 
                    parentSKU.OwnerTableView.DataSource = ViewState(ViewState("grdOR_DataSource_SKU").ToString)  
                    parentStyle.OwnerTableView.DataSource = ViewState(ViewState("grdOR_DataSource_Style").ToString)  
 
                    ViewState("grdOR_Event") = ""  
                    ViewState("grdOR_DataSource_SKU") = ""  
                    ViewState("grdOR_DataSource_Style") = ""  
 
                End If  
 
            End If  
 
        End If  
 
    End Sub  
 
    Protected Sub grdOR_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles grdOR.ItemCommand  
 
        Select Case e.CommandName  
 
            Case "ZEROSTYLE"  
 
                Dim StyleItem As GridDataItem = CType(e.Item, GridDataItem)  
                Dim dtStyle As DataTable = ViewState(grdOR.ClientID)  
                Dim SSN As String = StyleItem.OwnerTableView.DataKeyValues(StyleItem.ItemIndex)("STYL_SEQ_NUM").ToString  
                Dim Revised As String = StyleItem.OwnerTableView.DataKeyValues(StyleItem.ItemIndex)("RVD_QTY").ToString  
                  
                ZeroParentRow(StyleItem, dtStyle, SSN, e.Canceled)  
 
                StyleItem.CssClass = "ZeroedOut" 
 
                If StyleItem.Expanded Then  
 
                    For Each SKUItem As GridDataItem In StyleItem.ChildItem.NestedTableViews(0).Items  
 
                        Dim dtSKU As DataTable = ViewState(SKUItem.OwnerTableView.Name)  
 
                        ZeroParentRow(SKUItem, dtSKU, SSN, e.Canceled)  
 
                    Next  
 
                    StyleItem.Expanded = True 
 
                End If  
 
            Case "ZEROSKU"  
 
        End Select  
 
    End Sub  
 
    Public Sub ZeroParentRow(ByRef RowItem As GridDataItem, ByRef dt As DataTable, ByVal SSN As String, ByRef Canceled As Boolean)  
 
        Dim changedRows() As DataRow = dt.Select("STYL_SEQ_NUM = " & SSN)  
 
        If (changedRows.Length <> 1) Then  
            'MeMe.Label1.Text = Me.Label1.Text + "Unable to locate the Order for updating."  
            Canceled = True 
            Return  
        End If  
 
        changedRows(0).BeginEdit()  
 
        Try  
 
            changedRows(0)("RVD_QTY") = 0  
            changedRows(0).EndEdit()  
            changedRows(0).AcceptChanges()  
 
            grdOR.DataSource = dt 
            'grdOR.Rebind()  
            ViewState(RowItem.OwnerTableView.ClientID) = dt  
 
            'RowItem.Expanded = True 
 
        Catch ex As Exception  
 
            changedRows(0).CancelEdit()  
            'Label1Label1.Text = Label1.Text & "Unable to update Orders. Reason: " & ex.Message  
            Canceled = True 
 
        End Try  
 
    End Sub  
 
    Protected Sub grdOR_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles grdOR.NeedDataSource  
 
        grdOR.DataSource = PopulateStyleLevel()  
        ViewState(grdOR.ClientID) = grdOR.DataSource  
 
    End Sub  
 
    Private Function CalculateStoreTotal(ByVal dt As DataTable) As Integer  
 
        Dim newValues As New Hashtable  
        Dim Total As Integer = 0 
 
        For Each r As DataRow In dt.Rows  
 
            Total += Convert.ToInt32(r("RVD_QTY"))  
 
        Next  
 
        Return Total  
 
    End Function      
 
    Private Function PopulateStyleLevel() As DataTable  
 
        Dim dt As New DataTable  
        Dim c1 As New DataColumn  
        Dim c2 As New DataColumn  
        Dim c3 As New DataColumn  
        Dim c4 As New DataColumn  
 
        c1.ColumnName = "ITEM_DES" 
        c2.ColumnName = "VEN_STYL_NUM" 
        c3.ColumnName = "STYL_SEQ_NUM" 
        c4.ColumnName = "RVD_QTY" 
 
        dt.Columns.Add(c1)  
        dt.Columns.Add(c2)  
        dt.Columns.Add(c3)  
        dt.Columns.Add(c4)  
 
        Dim r As DataRow = dt.NewRow  
        r("ITEM_DES") = "Test Item 1"  
        r("VEN_STYL_NUM") = "TEST100"  
        r("STYL_SEQ_NUM") = "0123456789999"  
        r("RVD_QTY") = "20"  
        dt.Rows.Add(r)  
 
        r = dt.NewRow  
        r("ITEM_DES") = "Test Item 2"  
        r("VEN_STYL_NUM") = "TEST200"  
        r("STYL_SEQ_NUM") = "0123456788888"  
        r("RVD_QTY") = "10"  
        dt.Rows.Add(r)  
 
        'grdOR.DataSource = dt 
        'grdOR.DataSource = New DataView(dt)  
        'grdOR.DataBind()  
 
        Return dt  
 
    End Function  
 
    Private Function PopulateSKULevel(ByVal SSN As String) As DataTable  
 
        Dim dt As New DataTable  
        Dim c1 As New DataColumn  
        Dim c2 As New DataColumn  
        Dim c3 As New DataColumn  
        Dim c4 As New DataColumn  
        Dim c5 As New DataColumn  
 
        c1.ColumnName = "CLR_CDE" 
        c2.ColumnName = "CLR_DCD" 
        c3.ColumnName = "STYL_SEQ_NUM" 
        c4.ColumnName = "MSC_MDSE_NUM" 
        c5.ColumnName = "RVD_QTY" 
 
        dt.Columns.Add(c1)  
        dt.Columns.Add(c2)  
        dt.Columns.Add(c3)  
        dt.Columns.Add(c4)  
        dt.Columns.Add(c5)  
 
        Dim r As DataRow = dt.NewRow  
        r("CLR_CDE") = "100"  
        r("CLR_DCD") = "BLUE"  
        r("STYL_SEQ_NUM") = "0123456789999"  
        r("MSC_MDSE_NUM") = "0123456789999"  
        r("RVD_QTY") = "20"  
        dt.Rows.Add(r)  
 
        r = dt.NewRow  
        r("CLR_CDE") = "200"  
        r("CLR_DCD") = "RED"  
        r("STYL_SEQ_NUM") = "0123456788888"  
        r("MSC_MDSE_NUM") = "0123456788888"  
        r("RVD_QTY") = "10"  
        dt.Rows.Add(r)  
 
        r = dt.NewRow  
        r("CLR_CDE") = "300"  
        r("CLR_DCD") = "YELLOW"  
        r("STYL_SEQ_NUM") = "0123456788888"  
        r("MSC_MDSE_NUM") = "0123456787777"  
        r("RVD_QTY") = "40"  
        dt.Rows.Add(r)  
 
        Dim rows() As DataRow = dt.Select("STYL_SEQ_NUM = '" & SSN & "'")  
        Dim dtRet As DataTable = dt.Clone  
 
        For Each row As DataRow In rows  
 
            r = dtRet.NewRow  
            r(0) = row(0)  
            r(1) = row(1)  
            r(2) = row(2)  
            r(3) = row(3)  
            r(4) = row(4)  
            dtRet.Rows.Add(r)  
 
        Next  
 
        'dtRet.TableName = "SKU" 
 
        Return dtRet  
 
    End Function  
 
    Private Function PopulateStoreLevel(ByVal MSC As String) As DataTable  
 
        Dim dt As New DataTable  
        Dim c1 As New DataColumn  
        Dim c2 As New DataColumn  
        Dim c3 As New DataColumn  
        Dim c4 As New DataColumn  
 
        c1.ColumnName = "STOR_CDE" 
        c2.ColumnName = "ORDR_QTY" 
        c3.ColumnName = "MSC_MDSE_NUM" 
        c4.ColumnName = "RVD_QTY" 
 
        dt.Columns.Add(c1)  
        dt.Columns.Add(c2)  
        dt.Columns.Add(c3)  
        dt.Columns.Add(c4)  
 
        Dim r As DataRow = dt.NewRow  
        r("STOR_CDE") = "21"  
        r("ORDR_QTY") = "5"  
        r("MSC_MDSE_NUM") = "0123456789999"  
        r("RVD_QTY") = "20"  
        dt.Rows.Add(r)  
 
        r = dt.NewRow  
        r("STOR_CDE") = "54"  
        r("ORDR_QTY") = "7"  
        r("MSC_MDSE_NUM") = "0123456788888"  
        r("RVD_QTY") = "10"  
        dt.Rows.Add(r)  
 
        r = dt.NewRow  
        r("STOR_CDE") = "67"  
        r("ORDR_QTY") = "5"  
        r("MSC_MDSE_NUM") = "0123456787777"  
        r("RVD_QTY") = "40"  
        dt.Rows.Add(r)  
 
        Dim rows() As DataRow = dt.Select("MSC_MDSE_NUM = '" & MSC & "'")  
        Dim dtRet As DataTable = dt.Clone  
 
        For Each row As DataRow In rows  
 
            r = dtRet.NewRow  
            r(0) = row(0)  
            r(1) = row(1)  
            r(2) = row(2)  
            r(3) = row(3)  
            dtRet.Rows.Add(r)  
 
        Next  
 
        Return dtRet  
 
    End Function  
 
End Class  
 
Daniel
Telerik team
 answered on 16 Oct 2008
1 answer
128 views
Trying to use the drop down control on a modal window, but when you drop down it goes behind the modal.  Making it un-usable.

Any way to fix this?

I would upload a screen shot, but don't see how its doable.
Veselin Vasilev
Telerik team
 answered on 16 Oct 2008
7 answers
203 views
Hi

I have checked the forum but didn't find any Solution
I have 2 ComboBox in which MarkFirstMatch is true  and Allowcustom Text is fasle.
 
When i select an item from 1st Combox it doesn't fire SelectedIndex

So please let me know if there is a fix for this .Did download new Version

Thanks
Kavya
Rosi
Telerik team
 answered on 16 Oct 2008
1 answer
417 views
Hi
   I am having  issue in my Rad Grid.When Try to add the new item using command item template.

I am getting the error message "Unable to cast object of type 'Telerik.Web.UI.GridCommanditem' to 'Telerik.Web.UI.GridEditableItem' "

When trying to add the new item or user from command item template.

Need help

My client side code is

<

telerik:RadGrid ID="RadGrid1" CssClass="RadGrid" EnableTheming="False" EnableEmbeddedBaseStylesheet="False" AllowSorting="True" AllowMultiRowSelection="true" AllowMultiRowEdit="true"

 

 

runat="server" Width="98%" AllowPaging="True" AutoGenerateColumns="False" PageSize="5" AllowAutomaticDeletes="True" >

 

 

<ItemStyle CssClass="RadGridItem"></ItemStyle>

 

 

<HeaderStyle CssClass="RadGridHeader"></HeaderStyle>

 

 

<PagerStyle Mode="Slider" alwaysvisible="True" pagebuttoncount="5" CssClass="RadGridPager"></PagerStyle>

 

 

<ClientSettings EnablePostBackOnRowClick="false">

 

 

<Selecting AllowRowSelect="true" />

 

 

</ClientSettings>

 

 

<MasterTableView CommandItemDisplay="Top" DataKeyNames="SUserID" EditMode="InPlace" AutoGenerateColumns="False" Width="100%">

 

 

<CommandItemTemplate>

 

 

<div style="padding:10px 0px;" class="newtd">

 

 

<table cellpadding ="0" cellspacing ="0" border ="0" width ="100%">

 

 

<tr>

 

 

<td style="padding-left:5px"> &nbsp;Filter : &nbsp;</td>

 

 

<td> <asp:TextBox autocomplete="off" ID="txtSearch" runat="server" OnTextChanged="txtSearch_TextChanged"></asp:TextBox>&nbsp;</td>

 

 

<td style="padding-left:40px"><telerik:RadCombobox ID="rcbFieldName" runat="server" Skin="WebBlue" AllowCustomText="True" width="140px" EmptyMessage="-------Select-------" CausesValidation="false">

 

 

<Items>

 

 

<telerik:RadComboBoxItem Text="Email" Value="Email" />

 

 

</Items>

 

 

</telerik:RadCombobox>&nbsp;&nbsp;</td>

 

 

<td align ="left" style="padding-right:40px">

 

 

<asp:ImageButton ID="btnSearch" runat="server" CommandName="btnSearch" ImageUrl="~/Images/icons/Zoom.gif" ImageAlign="Bottom" CausesValidation="false"/>

 

 

</td>

 

 

<td align="right" style="padding:10px;" valign="middle">

 

 

<asp:LinkButton Style="vertical-align: bottom" ID="btnEditSelected" runat="server"

 

 

CommandName="EditSelected" CausesValidation="false" Visible='<%# RadGrid1.EditIndexes.Count = 0 %>' ><img style="border:0px;vertical-align:middle;" alt="" src="../Images/icons/Edit.gif" /> Edit Selected PowerAdmin</asp:LinkButton>

 

 

<asp:LinkButton ID="btnUpdateEdited" runat="server" CommandName="UpdateEdited" Visible='<%# RadGrid1.EditIndexes.Count > 0 %>'><img style="border:0px;vertical-align:middle;" alt="" src="../Images/icons/Save.gif" /> Update PowerAdmin</asp:LinkButton>

 

 

&nbsp;

 

 

<asp:LinkButton ID="btnInsert" runat="server" CommandName="InitInsert" Visible='<%# Not RadGrid1.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="../Images/icons/Add.gif" /> Add new PowerAdmin</asp:LinkButton>&nbsp;

 

 

<asp:LinkButton ID="LinkButton3" runat="server" CommandName="PerformInsert" Visible='<%# RadGrid1.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="../Images/icons/Add.gif" /> Add this PowerAdmin</asp:LinkButton>&nbsp;

 

 

<asp:LinkButton ID="btnCancel" runat="server" CommandName="CancelAll" CausesValidation="false" Visible='<%# RadGrid1.EditIndexes.Count > 0 Or RadGrid1.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="../Images/icons/Cancel.gif" /> Cancel</asp:LinkButton>

 

 

&nbsp;&nbsp;

 

 

<asp:LinkButton ID="LinkButton1" OnClientClick="javascript:return confirm('Are You Sure ?');"

 

 

runat="server" CommandName="DeleteSelected" CausesValidation="false" ><img style="border:0px;vertical-align:middle;" alt="" src="../Images/icons/Delet.gif" /> Delete Selected PowerAdmin</asp:LinkButton>

 

 

&nbsp;&nbsp;&nbsp;

 

 

<asp:LinkButton ID="LinkButton4" runat="server" CommandName="RebindGrid"><img style="border:0px;vertical-align:middle;" alt="" src="../Images/icons/Refresh.gif" /> Refresh </asp:LinkButton>

 

 

</td>

 

 

</tr>

 

 

</table>

 

 

</div>

 

 

</CommandItemTemplate>

 

 

<Columns>

 

 

 

<telerik:GridTemplateColumn UniqueName="SrlNo" AllowFiltering="False" ItemStyle-HorizontalAlign="Left" ItemStyle-Width="2%" >

 

 

<ItemTemplate >

 

 

<asp:Label ID="lblSrlNo" runat="server" />&nbsp;&nbsp;

 

 

</ItemTemplate>

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridClientSelectColumn HeaderStyle-Width="3%" />

 

 

<telerik:GridBoundColumn DataField="SUserID" UniqueName="SUserID" Visible="False" ReadOnly="True"></telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="Email" UniqueName="Email" SortExpression="Email" HeaderText="Email" ShowSortIcon="False" >

 

 

<ItemStyle HorizontalAlign="Left" />

 

 

</telerik:GridBoundColumn>

 

 

 

<telerik:GridTemplateColumn UniqueName="Password" HeaderText="Password" >

 

 

<ItemTemplate>

 

 

<asp:HyperLink ID="hplReset" style="cursor:pointer" runat="server" OnClick='<%# "fn_Change(this," & Eval("SUserId","{0:#}") & ")" %>'

 

 

Text="Reset">

 

 

</asp:HyperLink>

 

 

</ItemTemplate>

 

 

<EditItemTemplate >

 

 

 

<asp:HyperLink ID="hplReset1" style="cursor:pointer" runat="server" OnClick='<%# "fn_Change(this," & Eval("SUserId","{0:#}") & ")" %>' Text="Reset"></asp:HyperLink>

 

 

<asp:Label ID="lblpwd" runat="server" Visible="false" Text="Enter Password" ></asp:Label><font color="red" >*</font>:&nbsp;<asp:TextBox ID="txtpwd" runat="server" Visible="false"></asp:TextBox>&nbsp;

 

 

<asp:RequiredFieldValidator ID="RequiredFieldValidator2"

 

 

ControlToValidate="txtpwd" ErrorMessage="Enter Password" runat="server" ></asp:RequiredFieldValidator>

 

 

<asp:Label ID="lblrepwd" runat="server" Visible="false" Text="Retype Password" ></asp:Label><font color="red" >*</font>:&nbsp;<asp:TextBox ID="txtrepwd" runat="server" Visible="false"></asp:TextBox>

 

 

<asp:RequiredFieldValidator ID="reqretypepassword"

 

 

ControlToValidate="txtrepwd" ErrorMessage="Re-Type Password" runat="server" ></asp:RequiredFieldValidator>

 

 

</EditItemTemplate>

 

 

<ItemStyle HorizontalAlign="Left" />

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridTemplateColumn DataField="UserStatus" UniqueName="UserStatus" HeaderButtonType="TextButton" HeaderText="UserStatus" ><ItemTemplate>

 

 

<asp:Label ID="lblStatus" runat="server" text='<%# IIf(Trim(""& Eval("UserStatus"))= 0,"Enabled","Disabled") %>' />

 

 

</ItemTemplate>

 

 

<EditItemTemplate >

 

 

<div id="checkstatus">

 

 

<asp:RadioButton GroupName="grpuserstatus" runat="server" ID="checkDisable" text="Disabled" Checked='<%# IIf(Val(""& Eval("UserStatus"))= 0,"False","True") %>'/>

 

 

<asp:RadioButton GroupName="grpuserstatus" runat="server" ID="checkEnable" text="Enabled" Checked='<%# IIf(Val(""& Eval("UserStatus"))= 0,"True","False") %>'/>

 

 

</div>

 

 

</EditItemTemplate>

 

 

<ItemStyle HorizontalAlign="Left" />

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridEditCommandColumn UniqueName="Editcolumn"/>

 

 

 

</Columns>

 

 

<EditFormSettings >

 

 

<FormTableItemStyle Wrap="False"></FormTableItemStyle>

 

 

<FormCaptionStyle CssClass="RadGridHeader"></FormCaptionStyle>

 

 

<FormMainTableStyle BackColor="White" GridLines="Horizontal" CellPadding="3" Width="100%" CellSpacing="0"></FormMainTableStyle>

 

 

<FormTableStyle CellSpacing="0" CellPadding="2" CssClass="module" Height="110px" BackColor="White" />

 

 

<FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>

 

 

<EditColumn CancelText="Cancel edit" InsertText="Insert Order" UniqueName="EditCommandColumn1" ButtonType="ImageButton" UpdateText="Update record">

 

 

</EditColumn>

 

 

<FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle>

 

 

<FormTemplate>

 

 

<table cellpadding="3" cellspacing="0" width="98%" border="0">

 

 

<tr><td style="height:20px;"></td></tr>

 

 

<tr>

 

 

<td align="right" width="40%" >Email&nbsp;<font color="red" >*</font>:&nbsp;</td>

 

 

<td align="left" width="60%" ><asp:TextBox ID="txtEmail" runat="server" ></asp:TextBox>

 

 

<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtEmail"

 

 

Display="Dynamic" CssClass="errormsg" ErrorMessage="Enter Email"></asp:RequiredFieldValidator><asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtEmail"

 

 

Display="Dynamic" CssClass="errormsg" ErrorMessage="Invalid Email" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator></td>

 

 

</tr>

 

 

<tr><td>

 

 

 

<table cellpadding="0" cellspacing="0" border="0" width="100%">

 

 

<tr><td align="right" width="20%">Password&nbsp;<font color="red" >*</font>:&nbsp;</td>

 

 

<td align="left" width="80%" ><asp:TextBox ID="txtPassword" TextMode="Password" runat="server" MaxLength="10" ></asp:TextBox><asp:RequiredFieldValidator Enabled="false"

 

 

ID="reqPassword" runat="server" CssClass="errormsg" ControlToValidate="txtPassword" Display="Dynamic" ErrorMessage="Enter Password"></asp:RequiredFieldValidator><asp:RegularExpressionValidator Enabled="false"

 

 

ID="regPassword" runat="server" ControlToValidate="txtPassword" CssClass="errormsg" Display="Dynamic" ErrorMessage="Invalid Password" ValidationExpression="\w{6,10}"></asp:RegularExpressionValidator></td></tr>

 

 

<tr><td align="right" width="20%">Retype Password&nbsp;<font color="red" >*</font>:&nbsp;</td>

 

 

<td align="left" width="80%" ><asp:TextBox ID="txtRePassword" TextMode="Password" runat="server" MaxLength="10" ></asp:TextBox><asp:RequiredFieldValidator Enabled="false"

 

 

ID="reqRePassword" runat="server" ControlToValidate="txtRePassword" CssClass="errormsg" Display="Dynamic" ErrorMessage="Enter Re-Type Password"></asp:RequiredFieldValidator><asp:RegularExpressionValidator Enabled="false"

 

 

ID="regRePassword" runat="server" ControlToValidate="txtRePassword" CssClass="errormsg" Display="Dynamic" ErrorMessage="Invalid Re-Type Password" ValidationExpression="\w{6,10}"></asp:RegularExpressionValidator><asp:CompareValidator

 

 

ID="cmpPassword" runat="server" ControlToCompare="txtPassword" ControlToValidate="txtRePassword" CssClass="errormsg" Display="Dynamic" ErrorMessage="Password Mismatch" Enabled="false" ></asp:CompareValidator></td></tr>

 

 

</table>

 

 

</td>

 

 

</tr>

 

 

</table>

 

 

</FormTemplate>

 

 

</EditFormSettings>

 

 

<ExpandCollapseColumn>

 

 

<HeaderStyle Width="20px"></HeaderStyle>

 

 

</ExpandCollapseColumn>

 

 

<RowIndicatorColumn>

 

 

<HeaderStyle Width="20px"></HeaderStyle>

 

 

</RowIndicatorColumn>

 

 

</MasterTableView>

 

 

<FilterMenu EnableTheming="True" Skin="WebBlue" enableembeddedbasestylesheet="False">

 

 

<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>

 

 

</FilterMenu>

 

 

<AlternatingItemStyle CssClass="RadGridItem"></AlternatingItemStyle>

 

 

<SortingSettings SortToolTip="Click here to sort Email"></SortingSettings>

 

 

</telerik:RadGrid>

 

Server side code is :

Imports

Telerik.Web.UI

 

Partial

Class Clients_ManagePAdmin

 

 

Inherits System.Web.UI.Page

 

 

Dim oDB As New CMSDatabase

 

 

Dim SqlQry As String = ""

 

 

Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit

 

 

Dim UserTheme As MyThemes = Val(Session("@Theme"))

 

 

Me.Theme = UserTheme.ToString

 

 

Dim RadSkin As String = Replace(UserTheme.ToString, "_", "")

 

RadGrid1.Skin = RadSkin

 

'rcbFieldName.Skin = RadSkin

 

 

End Sub

 

 

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

 

Ajax.Utility.RegisterTypeForAjax(

Me.GetType)

 

 

If Not Page.IsPostBack Then

 

 

Select Case UCase(Request.QueryString("from"))

 

 

Case "ADD"

 

lblMsg.Text = library.GetXMLMessage(8)

 

Case "EDIT"

 

lblMsg.Text = library.GetXMLMessage(9)

 

Case "DELETE"

 

lblMsg.Text = library.GetXMLMessage(10)

 

End Select

 

 

End If

 

 

End Sub

 

<Ajax.JavascriptMethod()> _

 

Function updaterecords(ByVal Passs, ByVal SUserId) As Boolean

 

 

Dim SqlQry As String = "UPDATE siteusers set password='" & NDCryption.Encrypt(Passs) & "' where SUserId = " & SUserId & ""

 

 

Return oDB.ExecuteNonQuery(SqlQry)

 

 

End Function

 

 

Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource

 

 

Dim sqlqry As String

 

 

Dim DT As New DataTable

 

sqlqry =

"select SUserId,Email,Password,UserStatus from siteusers where usertype= " & UserType.PowerAdmin

 

 

'sqlqry = "select SUserId,Email,Password, case UserStatus when 0 then 'true' else 'false' end as UserStatus from siteusers where usertype= " & UserType.PowerAdmin

 

 

If oDB.IsExist(sqlqry) = True Then

 

DT = oDB.GetDataTable(sqlqry)

RadGrid1.Visible =

True

 

RadGrid1.DataSource = DT

 

Else

 

RadGrid1.Visible =

False

 

 

End If

 

 

End Sub

 

 

Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound

 

 

If e.Item.ItemType = GridItemType.AlternatingItem Or e.Item.ItemType = Telerik.Web.UI.GridItemType.Item Then

 

 

Dim lbl As Label

 

lbl =

CType(e.Item.FindControl("lblSrlNo"), Label)

 

lbl.Text = e.Item.ItemIndex + 1

 

Try

 

 

Dim lblpass As Label

 

lblpass =

CType(e.Item.FindControl("Password"), Label)

 

lblpass.Text = NDCryption.Decrypt(lblpass.Text)

 

If Trim(lblpass.Text) <> "" Then

 

lblpass.Text =

"".PadLeft(Len(lblpass.Text), "*")

 

 

End If

 

 

'Response.Write(e.Item.Cells(7).Text)

 

 

'e.Item.Cells(7).Style.Add("display", "none")

 

 

Catch ex As Exception

 

 

End Try

 

 

End If

 

 

If TypeOf e.Item Is GridEditFormItem AndAlso e.Item.IsInEditMode Then

 

 

 

 

End If

 

 

End Sub

 

 

Private Sub RadGrid1_SortCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridSortCommandEventArgs) Handles RadGrid1.SortCommand

 

 

If e.Item.OwnerTableView.DataMember = "Orders" And e.SortExpression = "Email" Then

 

e.Canceled =

True

 

 

Dim expression As New GridSortExpression()

 

expression.FieldName =

"Email"

 

 

If e.Item.OwnerTableView.SortExpressions.Count = 0 OrElse e.Item.OwnerTableView.SortExpressions(0).FieldName <> e.SortExpression Then

 

expression.SortOrder = GridSortOrder.Descending

 

ElseIf e.Item.OwnerTableView.SortExpressions(0).SortOrder = GridSortOrder.Descending Then

 

expression.SortOrder = GridSortOrder.Ascending

 

ElseIf e.Item.OwnerTableView.SortExpressions(0).SortOrder = GridSortOrder.Ascending Then

 

expression.SortOrder = GridSortOrder.None

 

End If

 

e.Item.OwnerTableView.SortExpressions.AddSortExpression(expression)

e.Item.OwnerTableView.Rebind()

 

End If

 

 

End Sub 'RadGrid1_SortCommand

 

 

Protected Sub txtSearch_TextChanged(ByVal sender As Object, ByVal e As EventArgs)

 

 

Dim txt As TextBox = TryCast(DirectCast(sender, TextBox), TextBox)

 

 

Dim list As RadComboBox = DirectCast(((txt.NamingContainer).FindControl("rcbFieldName")), RadComboBox)

 

 

Dim [option] As String

 

 

If list.SelectedValue = "SUserId" OrElse list.SelectedValue = "UserStatus" Then

 

[option] =

" = "

 

 

Else

 

[option] =

" LIKE "

 

 

End If

 

 

Dim filterExpression As String

 

 

If [option] = " = " Then

 

filterExpression =

"(" + list.SelectedValue + [option] + txt.Text + ")"

 

 

Else

 

filterExpression =

"(" + list.SelectedValue + [option] + "'" + txt.Text + "%'" + ")"

 

 

End If

 

RadGrid1.MasterTableView.FilterExpression = filterExpression

RadGrid1.MasterTableView.Rebind()

 

End Sub

 

 

Protected Sub RadGrid1_UpdateCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.UpdateCommand

 

 

Dim item As GridEditableItem = TryCast(e.Item, GridEditableItem)

 

 

Dim editor As GridTextBoxColumnEditor = DirectCast(item.EditManager.GetColumnEditor("Email"), GridTextBoxColumnEditor)

 

 

Dim txtsid As TextBox

 

txtsid =

CType(e.Item.OwnerTableView.Items(e.Item.ItemIndex)("SUserID").Controls(0), TextBox)

 

 

Dim radioEnable = CType(item.FindControl("checkEnable"), RadioButton).Checked

 

SqlQry =

"select Email from SiteUsers where Email='" & editor.TextBoxControl.Text & "' and SuserId <> " & txtsid.Text

 

 

If oDB.ExecuteScaler(SqlQry) = "" Then

 

SqlQry =

"Update SiteUsers Set Email='" & editor.TextBoxControl.Text & "',userstatus=" & IIf(radioEnable = True, 0, 1) & " where SUserId = " & txtsid.Text

 

oDB.ExecuteNonQuery(SqlQry)

 

Else

 

lblMsg.Text =

"Email Already Exists"

 

 

End If

 

 

End Sub

 

 

Protected Sub RadGrid1_DeleteCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.DeleteCommand

 

 

Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)

 

 

Try

 

hidUpdateuser.Value =

""

 

SqlQry =

"DELETE from SiteUsers where SuserId='" & e.Item.Cells(4).Text & "'"

 

oDB.ExecuteNonQuery(SqlQry)

hidUpdateuser.Value =

"Deleted"

 

 

Catch ex As Exception

 

RadGrid1.Controls.Add(

New LiteralControl("Unable to delete Employee. Reason: " + ex.Message))

 

e.Canceled =

True

 

 

End Try

 

 

End Sub

 

#

Region "******************** Ajax Function *****************************"

 

<Ajax.JavascriptMethod()> _

 

Function IsEmailExist(ByVal Email As String) As Boolean

 

 

Dim SqlQry As String = ""

 

SqlQry =

"Select * from SiteUsers where UPPER(Email) like '" & UCase(Email) & "'"

 

IsEmailExist = oDb.IsExist(SqlQry)

 

End Function

 

#

End Region

 

 

'Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click

 

 

' If Page.IsValid Then

 

 

' Dim SqlQry As String = ""

 

 

' Dim Password As String = ""

 

 

' Dim SuserId As String = ""

 

 

' Password = NDCryption.Encrypt(txtPassword.Text)

 

 

' SqlQry = "insert into SiteUsers([ClientID], [Email], [Password], [UserStatus],[UserType],[Authenticate]) values (0,'" & txtEmail.Text.Trim & "','" & NDCryption.Encrypt(txtPassword.Text) & "',0," & UserType.PowerAdmin & "," & UserAuthenticate.CMSSite & ")"

 

 

' oDB.ExecuteNonQuery(SqlQry)

 

 

' Response.Redirect("ManagePAdmin.aspx?from=add&CID=" & Request.QueryString("CID") & "&SID=" & Request.QueryString("SID") & "&PID=" & Request.QueryString("PID"))

 

 

' End If

 

 

'End Sub

 

 

Protected Sub RadGrid1_PageIndexChanged(ByVal source As Object, ByVal e As Telerik.Web.UI.GridPageChangedEventArgs) Handles RadGrid1.PageIndexChanged

 

 

'e.Canceled = True

 

 

End Sub

 

 

 

Protected Sub RadGrid1_InsertCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.InsertCommand

 

 

Dim SqlQry As String = ""

 

 

Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)

 

 

Dim txtEmail As GridTextBoxColumnEditor = DirectCast(editedItem.EditManager.GetColumnEditor("Email"), GridTextBoxColumnEditor)

 

 

Dim txtPassword As TextBox = CType(editedItem.FindControl("txtpwd"), TextBox)

 

 

'Password = NDCryption.Encrypt(txtPassword.Text)

 

SqlQry =

"insert into SiteUsers([ClientID], [Email], [Password], [UserStatus],[UserType],[Authenticate]) values (0,'" & txtEmail.TextBoxControl.Text.Trim & "','" & NDCryption.Encrypt(txtPassword.Text) & "'," & UserStatue.Enabled & "," & UserType.PowerAdmin & "," & UserAuthenticate.CMSSite & ")"

 

oDB.ExecuteNonQuery(SqlQry)

 

End Sub

 

 

 

Private Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemCreated

 

 

If (TypeOf e.Item Is GridDataItem) Then

 

 

Dim dataItem As GridDataItem = CType(e.Item, GridDataItem)

 

 

 

ElseIf (TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode) Then

 

 

Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)

 

 

Dim editor As GridTextBoxColumnEditor = DirectCast(editedItem.EditManager.GetColumnEditor("Email"), GridTextBoxColumnEditor)

 

 

Dim cell As TableCell = DirectCast(editor.TextBoxControl.Parent, TableCell)

 

 

Dim validator As New RequiredFieldValidator

 

editor.TextBoxControl.ID =

"Email"

 

validator.ControlToValidate = editor.TextBoxControl.ID

validator.ErrorMessage =

"Enter Email Address"

 

 

 

 

 

'LiteralControl()

 

cell.Controls.Add(validator)

 

End If

 

 

End Sub

 

 

 

Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand

 

 

Select Case e.CommandName

 

 

Case RadGrid.InitInsertCommandName

 

e.Canceled =

True

 

e.Item.OwnerTableView.InsertItem()

 

Dim Grid As RadGrid = CType(source, RadGrid)

 

Grid.MasterTableView.ClearEditItems()

 

Dim insertedItem As GridEditableItem = e.Item.OwnerTableView.GetInsertItem()

 

 

Dim txtPassword As TextBox = CType(insertedItem.FindControl("txtpwd"), TextBox)

 

 

Dim txtRePassword As TextBox = CType(insertedItem.FindControl("txtrepwd"), TextBox)

 

 

Dim lblrepwd As Label = CType(insertedItem.FindControl("lblrepwd"), Label)

 

 

Dim lblpwd As Label = CType(insertedItem.FindControl("lblpwd"), Label)

 

 

Dim hplReset1 As HyperLink = CType(insertedItem.FindControl("hplReset1"), HyperLink)

 

hplReset1.Visible =

False

 

lblpwd.Visible =

True

 

lblrepwd.Visible =

True

 

txtPassword.Visible =

True

 

txtRePassword.Visible =

True

 

txtPassword.TextMode = TextBoxMode.Password

txtRePassword.TextMode = TextBoxMode.Password

 

Case RadGrid.EditSelectedCommandName

 

e.Item.OwnerTableView.IsItemInserted =

False

 

 

End Select

 

 

End Sub

 

End

Class

 





Iana Tsolova
Telerik team
 answered on 16 Oct 2008
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?