Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
97 views
This code is loosely based on several of the demos. My main problem here is that when i run my program and happen to see my gridview the datas are not the same as with my datas in my table in my database.

And when i tried to hit the edit button.. and make some few changes.. it updates my gridview but not the same as my datas in my table in my database..

hope someone could lend a helping hand..

here's my code.. by the way i'm just a newbie in asp.net ..please be gentle.. thanks

ASPX

<%@ Page Language="VB" MasterPageFile="~/Admin/Admin.master" AutoEventWireup="false" CodeFile="TeacherRole.aspx.vb" Inherits="Admin_TeacherRole" title="Untitled Page" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
     
  
<html>
 
<body>
       <!-- content start -->
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
 
        <script type="text/javascript">
            function RowDblClick(sender, eventArgs) {
                sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
            }
        </script>
 
    </telerik:RadCodeBlock>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" 
        DefaultLoadingPanelID="RadAjaxLoadingPanel1">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
 
       <telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True"
            AllowPaging="True" AllowSorting="True" OnUpdateCommand = "RadGrid1_UpdateCommand"
            AutoGenerateEditColumn="True"  GridLines="None"
            Skin="Black"
        AllowAutomaticUpdates="True" ShowGroupPanel="True" GroupPanel-ID = "RadAjaxLoadingPanel1">
         
             <MasterTableView EditMode="PopUp" AutoGenerateColumns="False"  DataKeyNames = "user_id"
                CommandItemDisplay="Top">
                 
                <Columns>
                     <telerik:GridBoundColumn DataField="user_id" DataType="System.Int32"
                        HeaderText="User ID" SortExpression="user_id" UniqueName="user_id" ReadOnly="True">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="lastname" HeaderText="Last Name"
                        SortExpression="lastname" UniqueName="lastname" ReadOnly="False">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="firstname" HeaderText="First Name"
                        SortExpression="firstname" UniqueName="firstname" ReadOnly="False">
                    </telerik:GridBoundColumn>
 
                </Columns>
                 
                <EditFormSettings CaptionFormatString="Edit User ID: {0}"  CaptionDataField="user_id" PopUpSettings-Modal="True" PopUpSettings-ScrollBars="Auto"
                EditFormType= "AutoGenerated">
                    <FormTableItemStyle Width="100%" Height="29px"></FormTableItemStyle>
                    <FormTableStyle GridLines="None" CellSpacing="0" CellPadding="2"></FormTableStyle>
                    <FormStyle Width="100%" BackColor="#eef2ea"></FormStyle>
                    <EditColumn ButtonType="PushButton" />
                     
<PopUpSettings ScrollBars="Auto" Modal="True"></PopUpSettings>
                </EditFormSettings>
            </MasterTableView>
             <ClientSettings AllowDragToGroup="True">
                <Scrolling AllowScroll="True" UseStaticHeaders="True" />
                <ClientEvents OnRowDblClick="RowDblClick" />
            </ClientSettings>
        </telerik:RadGrid>
   
    
    <!-- content end -->
 
</body>
</html>
</asp:Content>


VB
Imports System
Imports System.Configuration
Imports System.Data
Imports System.Data.Common
Imports System.Data.SqlClient
Imports System.Globalization
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports Telerik.Web.UI
 
Partial Class Admin_TeacherRole
    Inherits System.Web.UI.Page
 
    Private Sub RadGrid1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid1.PreRender
        If Not IsPostBack Then
            For Each item As GridItem In RadGrid1.MasterTableView.Items
                If TypeOf item Is GridEditableItem Then
                    Dim editableItem As GridEditableItem = CType(item, GridDataItem)
                    editableItem.Edit = True
                End If
            Next
            RadGrid1.Rebind()
        End If
    End Sub
    Private Sub Page_PreRender(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.PreRender
        If Not MyBase.IsPostBack Then
            Me.RadGrid1.MasterTableView.Items(0).Edit = True
            Me.RadGrid1.MasterTableView.Rebind()
        End If
    End Sub
    Public ReadOnly Property UserData() As DataSet
        Get
            Dim obj As Object = Me.Session("UserData")
            If Not obj Is Nothing Then
                Return CType(obj, DataSet)
            End If
 
            Dim MyUserData As DataSet = New DataSet
 
            Dim ConnString As String = ConfigurationManager.ConnectionStrings("ProLearnConnectionString").ConnectionString
            Dim conn As SqlConnection = New SqlConnection(ConnString)
            Dim adapter As SqlDataAdapter = New SqlDataAdapter
            adapter.SelectCommand = New SqlCommand("SELECT user_id, lastname, firstname FROM tblStudents ORDER BY user_id", conn)
 
            adapter.Fill(MyUserData, "tblStudents")
 
            Me.Session("UserData") = MyUserData
 
            Return MyUserData
        End Get
    End Property
    Private Sub RadGrid1_NeedDataSource(ByVal source As System.Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
        RadGrid1.DataSource = Me.UserData
        Me.UserData.Tables("tblStudents").PrimaryKey = New DataColumn() {Me.UserData.Tables("tblStudents").Columns("user_id")}
    End Sub
    Protected Sub RadGrid1_UpdateCommand(ByVal source As System.Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.UpdateCommand
 
        Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)
        Dim editMan As GridEditManager = editedItem.EditManager
 
        Dim column As GridColumn
 
        For Each column In e.Item.OwnerTableView.Columns
            If TypeOf column Is IGridEditableColumn Then
                Dim editableCol As IGridEditableColumn = CType(column, IGridEditableColumn)
                If (editableCol.IsEditable) Then
                    Dim editor As IGridColumnEditor = editMan.GetColumnEditor(editableCol)
 
                    Dim editorType As String = CType(editor, Object).ToString()
                    Dim editorText As String = "unknown"
                    Dim editorValue As Object = Nothing
 
                    If (TypeOf editor Is GridTextColumnEditor) Then
                        editorText = CType(editor, GridTextColumnEditor).Text
                        editorValue = CType(editor, GridTextColumnEditor).Text
                    End If
 
                    If (TypeOf editor Is GridBoolColumnEditor) Then
                        editorText = CType(editor, GridBoolColumnEditor).Value.ToString()
                        editorValue = CType(editor, GridBoolColumnEditor).Value
                    End If
 
                    If (TypeOf editor Is GridDropDownColumnEditor) Then
                        editorText = CType(editor, GridDropDownColumnEditor).SelectedText & "; " & CType(editor, GridDropDownColumnEditor).SelectedValue
                        editorValue = CType(editor, GridDropDownColumnEditor).SelectedValue
                    End If
 
                    Try
                        Dim changedRows As DataRow() = Me.UserData.Tables("tblStudents").Select("user_id = " & editedItem.OwnerTableView.DataKeyValues(editedItem.ItemIndex)("user_id"))
                        changedRows(0)(column.UniqueName) = editorValue
                        Me.UserData.Tables("tblStudents").AcceptChanges()
 
                    Catch ex As Exception
                        RadGrid1.Controls.Add(New LiteralControl("<strong>Unable to set value of column '" & column.UniqueName & "'</strong> - " + ex.Message))
                        e.Canceled = True
                    End Try
 
                End If
            End If
        Next
 
 
    End Sub
 
End Class
Radoslav
Telerik team
 answered on 29 Jul 2010
1 answer
75 views
Hi Telerik Support team,
                 I am using Telerik Radgrid,RadTree and RadTabcontrol for my website.When i browse in IE8 it has a good response rate.But when i use IE7 to browse it is really too slow.I think these might be a Telerik rendering problem.Hope you get me some solution.

Thanks
Deepan
 
   
Iana Tsolova
Telerik team
 answered on 29 Jul 2010
1 answer
187 views
Hello,
sorry but after several searches I could not find how to set filter conditions programmatically and show them in rad filter , any suggestion would be appreciated,
thanks
Nikolay Rusev
Telerik team
 answered on 29 Jul 2010
1 answer
118 views
OK so i have a Grid that Uses a Global Template.

I need to get a cell value of the Selected record to compare it for validation. All i seem to get client-side is the Template Column HTML

Here is my Code

<telerik:RadGrid ID="ClassGrid" runat="server" AllowMultiRowSelection="false" AutoGenerateColumns="False"
    OnNeedDataSource="ClassGrid_NeedDataSource" OnDataBound="ClassGrid_DataBound"
    Skin="WebBlue" GridLines="Both" ShowGroupPanel="false"  ShowHeader="true" OnItemDataBound="ClassGrid_ItemDataBound"
    AllowPaging="true" PageSize="10" AllowFilteringByColumn="true">
    <ExportSettings FileName="AvailableClassListExport" ExportOnlyData="true" OpenInNewWindow="True"
        HideStructureColumns="true">
    </ExportSettings>
    <MasterTableView Width="100%" CommandItemDisplay="TopAndBottom" PagerStyle-AlwaysVisible="true">
        <CommandItemSettings ShowAddNewRecordButton="false" ShowExportToExcelButton="true"
            ShowExportToCsvButton="true" ShowExportToWordButton="true" ShowExportToPdfButton="true" />
        <RowIndicatorColumn Visible="True">
        </RowIndicatorColumn>
        <ItemTemplate>
            <div style="float:left; padding: 0px 15px 0px 0px">
                <span><b>
                    <%#Eval("Class_Date", "{0:MMM dd, yyyy}")%></b>
                    <br />
                    <%#Eval("Class_Start_Time").ToString()%>
                    -
                    <%#Eval("Class_End_Time").ToString()%>
                    <br /><br /><br /><br /><br />
                </span>
            </div>
            <div>
                <span><b>
                    <%# Container.DataItem("Location_Name") %></b>
                    <%#IIf(Container.DataItem("isSpanish") = "Y", " (Spanish)", " (English)")%>
                    <br />
                    <%# Container.DataItem("Street_Address") %>
                    <br />
                    <%# Container.DataItem("City") %>,
                    <%# Container.DataItem("FK_State_Code") %>
                    <%# Container.DataItem("Zip") %>
                    <br />
                    <b>Cross Streets:</b>
                    <%# container.DataItem("Cross_Streets") %>
                    <br />
                    <!-- Map -->
                    <%#"<a href=""http://www.mapquest.com/maps?city=" + Container.DataItem("City") + "&state=" + Container.DataItem("FK_State_Code") + "&address=" + Container.DataItem("Street_Address") + "&zipcode=" + Container.DataItem("Zip") + "&country=US&CID=lfmaplink"" target=""_Blank"">Map</a>"%>
                    <!-- Seperator -->
                    |
                    <!-- Directions -->
                    <%#"<a href=""http://www.mapquest.com/maps?2c=" + Container.DataItem("City") + "&2s=" + Container.DataItem("FK_State_Code") + "&2a=" + Container.DataItem("Street_Address") + "&2z=" + Container.DataItem("Zip") + "&2y=US&Form=directions&CID=lfddlink"" target=""_Blank"">Directions</a>"%>
                    <br />
                    <br />
                </span>
            </div>
        </ItemTemplate>
        <Columns>
            <telerik:GridBoundColumn DataField="Class_ID" Display="false" HeaderText="ID">
            </telerik:GridBoundColumn>
            <telerik:GridDateTimeColumn UniqueName="Class_Date" DataField="Class_Date" Display="true" HeaderText="Date"
                AllowFiltering="true" PickerType="DatePicker" ItemStyle-Width="200px">
            </telerik:GridDateTimeColumn>
            <telerik:GridBoundColumn DataField="Class_Start_Time" Display="false" HeaderText="Start Time"
                AllowFiltering="true">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Class_End_Time" Display="false" HeaderText="End Time"
                AllowFiltering="true">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Location_Name" Display="false" HeaderText="Location">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Street_Address" Display="false" HeaderText="Address">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="City" Display="false" HeaderText="_City">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="FK_State_Code" Display="false" HeaderText="State">
            </telerik:GridBoundColumn>
            <telerik:GridDateTimeColumn DataField="Zip" Display="false" HeaderText="Zip">
            </telerik:GridDateTimeColumn>
            <telerik:GridBoundColumn DataField="Class_Status" Display="false" HeaderText="Status">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="isSpanish" Display="false" HeaderText="Spanish"
                AllowFiltering="true">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Location_DisplayCity" Display="false" HeaderText="City"
                AllowFiltering="true">
            </telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
    <ClientSettings ReorderColumnsOnClient="True" AllowDragToGroup="True" AllowColumnsReorder="True">
        <Selecting AllowRowSelect="True"></Selecting>
        <Resizing AllowRowResize="True" AllowColumnResize="True" EnableRealTimeResize="True"
            ResizeGridOnColumnResize="False"></Resizing>
    </ClientSettings>
    <GroupingSettings ShowUnGroupButton="true" />
    <PagerStyle Mode="NextPrevAndNumeric" Position="TopAndBottom" />
</telerik:RadGrid>


Heres my Test JS Code

<script type="text/javascript">
                window.setTimeout("TEST();", 5000);
                function TEST()
                {
                var _ClassGrid = $find("<%= AZADDClassGrid.ClientID %>_ClassGrid");
                     var _MasterTable = _ClassGrid.get_masterTableView();
                     var _SelectedRows = _ClassGrid.get_selectedItems();
 
                     if (_SelectedRows.length > 0) {
                         for (var i = 0; i < _SelectedRows.length; i++) {
                             var record = _SelectedRows[i];
                             var classDate = new Date(_MasterTable.getCellByColumnUniqueName(record, "Class_Date"));
                             alert(_MasterTable.getCellByColumnUniqueName(record, "Class_ID").innerHTML);
                         }
                     }
                }
            </script>
Tsvetoslav
Telerik team
 answered on 29 Jul 2010
1 answer
104 views
Hello all...

Does any know of a way to search for a row in a multi-paged grid, and move to that page/record in the grid?  I'm not talking about filtering the grid down to the record being searched for.

My users have a need where they are looking for a record, but not necessarily filter for that record.  They may simply want to start working from the record they are searching for and continue forward or backward depending on their needs.

My problem is, I can't seem to find a way, either through datasource, or the grid, to do this.  I can "guess" fairly accurately based on the # of records and the sort, but only if the table remains static.  These rows of data will change frequently, so that idea went out the window quick.

Anybody have any ideas?

Thanks, Greg
Tsvetoslav
Telerik team
 answered on 29 Jul 2010
1 answer
88 views
Hi,
I am using radgrid for the first time. I made allow paging property to true. i added a button to display the grid. when i clciked on buton it is displaying the first page............but when i clicked on next page on the radgrid its not displaying...........please help me with this....it is urgent for me............
Shinu
Top achievements
Rank 2
 answered on 29 Jul 2010
1 answer
81 views
All,
   I'm new to the Telerik controls (and loving them so far) - so please bear with me. I couldn't find a suitable answer by searching the forums, but I apologize if a similar question has been asked elsewhere.

I'm looking for guidance on the best way to achieve this.

I have a client who has a very strong urge for this application to work a certain way, and I know it's not typically how grids are edited/used, but if at all possible this is the situation I'm trying to code for (in Visual Studio 2008):

I have a RadGrid, defined in the aspx page, with no columns specified at design time.

At runtime, I'm loading a set of data that will have a variable number of columns.  there will be 1-2 columns of read-only textual data, and then a variable number of columns of nothing but checkboxes.  This is all that is contained in the grid.   The user should be able to select/unselect each checkbox, and when satisifed with their data they will then hit a submit button, at which point I will store all changes in one go.
basic layout looks a little like this:
            col1  col2   col3   col4   col5
ROW1             [x]   [x]    [ ]    [ ]    [ ]
ROW2             [ ]   [ ]    [x]    [ ]    [ ]
ROW3             [x]   [ ]    [ ]    [ ]    [ ]
ROW4             [ ]   [ ]    [ ]    [x]    [ ]


 This differs from typical grid-editing usage in that client absolutely refuses to click an 'edit' command button to put the row in an edit state, followed by a save button to end the edit session.  Too many clicks for what will be hundreds of checkboxes.

I started off using the examples listed here, defining a custom template to be used by the checkbox columns, however when I attempt to iterate through the MasterTableView Items collection, or through just the grid's item collection, calling FindControl with the proper name does not seem to return anything.   At this point, I'm not even that concerned about tracking only what changed (although that'd be nice) - If I could just get the checked value for each box for each row in the grid I'd be happy.

One complication may be that I'm running this in a Master Pages environment - if this is a known problem, I can back out of that design and leave it as a standalone page.

If anyone has any advice, I'd be most appreciative.
Phillip Martin
Top achievements
Rank 1
 answered on 29 Jul 2010
1 answer
135 views
Hi

I have a page on which I have added dynamic tooltips using RadToolManager and they work well, popping up from the rows of a RadGrid.

When I add any other component to the RadAjaxManager, however, the tooltips stop working and it seems that the OnAjaxUpdate event is not fired.

It is difficult for me to provide source code examples as the system contains proprietary concepts but I can provide more information if needed. I've added some small samples here and hopefully these will help.

Thanks!

Jim

Heres where I add the tooltip:

    protected void grdExistingStock_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
        {
            Control target = e.Item.FindControl("targetControl");
            if (!Object.Equals(target, null))
            {
                if (!Object.Equals(this.RadToolTipManager1, null))
                {
                    //Add the button (target) id to the tooltip manager
                    this.RadToolTipManager1.TargetControls.Add(target.ClientID, (e.Item as GridDataItem).GetDataKeyValue("STKCODE").ToString(), true);
                    this.RadToolTipManager1.BorderStyle = BorderStyle.Solid;
                    this.RadToolTipManager1.BorderWidth = 1;
                }
            }
        }
    }

and updating the tooltip:

    protected void OnAjaxUpdate(object sender, Telerik.Web.UI.ToolTipUpdateEventArgs args)
    {
        this.UpdateToolTip(args.Value, args.UpdatePanel);
    }

    private void UpdateToolTip(string elementID, UpdatePanel panel)
    {
        panel.UpdateMode = UpdatePanelUpdateMode.Conditional;

        Control ctrl = Page.LoadControl("~/StockSpecificationControl.ascx");
        StockSpecificationControl stockControl = (StockSpecificationControl)ctrl;

        stockControl.ShowInfoHeader = true;
        stockControl.StockCode = elementID;
        stockControl.SetUpUi();
        stockControl.DataBind();
        panel.ContentTemplateContainer.Controls.Add(ctrl);
    }

Jim Burns
Top achievements
Rank 1
 answered on 29 Jul 2010
2 answers
104 views
Hi,

In the RadChart is it possible to prevent the axis lines extending over the edges of the chart?  For example, where the X and Y axes meet the axis lines extend slightly further than the 0 mark.

Thanks
ns
Top achievements
Rank 1
 answered on 28 Jul 2010
7 answers
239 views
I wrote a page that opens a pop-up user control to insert an order item from a large grid of items
the grid is Linq to SQL
I am using VS2010 / .NET 4.0

after the insert the pop-up doesn't automatically close
maybe because I'm inserting into another database?

the grid of the calling program
<%@ Page Title="" Language="VB" MasterPageFile="~/Brunswick.master" AutoEventWireup="false" CodeFile="Items.aspx.vb" Inherits="Items" %>
<asp:Content ID="cntHead" ContentPlaceHolderID="cpHead" Runat="Server">
    <title>Brunswick Online Orders - Items</title>
<link href="Brunswick.css" rel="Stylesheet" />
</asp:Content>
<asp:Content ID="cntBody" ContentPlaceHolderID="cpHolder" Runat="Server">
    <telerik:RadScriptManager ID="rsManager" runat="server" />
    <telerik:RadCodeBlock ID="rcBlock" runat="server">
        <script type="text/javascript">
        function RowDblClick(sender, eventArgs) {
            sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
        }
        function doFilter(sender,e) {
            var masterTable = $find("<%= rgItems.ClientID %>").get_masterTableView();
            masterTable.filter(sender, sender.value, Telerik.Web.UI.GridFilterFunction.StartsWith, true);
        }
        </script>
    </telerik:RadCodeBlock>
    <telerik:RadAjaxManager ID="raManager" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="rgItems">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rgItems" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <table border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td colspan="2" align="center">
        <asp:Label ID="lblShowName" runat="server" />
        <asp:HiddenField ID="hdnDivisionID" runat="server" />
    </td>
    <td colspan="2" align="center">
        <asp:Button ID="btnReturn" Text="Return To Order" runat="server" />
    </td>
    </tr>
    <tr>
    <td>Dealer Number</td>
    <td>
        <asp:Label ID="lblDealerNumber" runat="server" />
    </td>
    <td>Dealer Name</td>
    <td>
        <asp:Label ID="lblDealerName" runat="server" />
        <asp:HiddenField ID="hdnOrderID" runat="server" />
    </td>
    </tr>
    <tr>
    <td colspan="4">
    <telerik:RadGrid ID="rgItems" AutoGenerateColumns="False" AllowPaging="True"
            runat="server" AllowFilteringByColumn="True" AllowSorting="True" GridLines="None">
        <GroupingSettings CaseSensitive="false" />
        <ClientSettings>
            <Scrolling AllowScroll="True" UseStaticHeaders="True"/>
        </ClientSettings>
        <MasterTableView DataKeyNames="ItemID" EditMode="PopUp">
        <Columns>
            <telerik:GridBoundColumn UniqueName="ItemID" DataField="ItemID" Visible="False">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn UniqueName="LNSPartNo" DataField="LNSPartNo" HeaderText="LNS Part No" HeaderStyle-Width="80px">
            </telerik:GridBoundColumn>
more columns here
            <telerik:GridBoundColumn UniqueName="ShowTenTerms" DataField="ShowTenTerms" HeaderText="Show Dat Terms" HeaderStyle-Width="60px" DataFormatString="{0:$###,###.##}" ShowFilterIcon="false">
            </telerik:GridBoundColumn>
        </Columns>
        <EditFormSettings UserControlName="OrderItem.ascx" EditFormType="WebUserControl">
        </EditFormSettings>
        </MasterTableView>
            <ClientSettings>
                <ClientEvents OnRowDblClick="RowDblClick" />
            </ClientSettings>
    </telerik:RadGrid>
    </td>
    </tr>
    </table>
</asp:Content>
and it's code behind
Imports Telerik.Web.UI
Imports System.Data

Partial Class Items
    Inherits System.Web.UI.Page

    Enum CostSource As Integer
        SpringDatingInvPrice = 1
        SpringDatingNetTerms = 2
        ShowOnlyInvPrice = 3
        ShowOnlyNetTerms = 4
        UserSpecified = 5
        Unspecified_Unknown = 6
    End Enum

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim OrderID, DivisionID As Integer
        Dim ws As CommonFunctions
        If Page.IsPostBack Then
        Else
            SaveQueryStringVariables()
            OrderID = CInt(hdnOrderID.Value)
            DivisionID = CInt(hdnDivisionID.Value)
            ws = New CommonFunctions
            rgItems.DataSource = ws.GetItems(DivisionID)
            rgItems.DataBind()
        End If
        ws = Nothing
    End Sub

    Private Sub SaveQueryStringVariables()
        Dim OrderID, DivisionID As Integer
        Dim ds As DataSet = Nothing
        Dim dr As DataRow = Nothing
        Dim ShowAbbreviation, ShowName, DealerName As String
        Dim DealerNumber As Int64 = 0
        Dim sb As StringBuilder = Nothing
        Dim ws As CommonFunctions

        ws = New CommonFunctions
        If Request.QueryString("OrderID") Is Nothing Then
            Exit Sub
        End If
        OrderID = Request.QueryString("OrderID")
        hdnOrderID.Value = OrderID
        ds = ws.GetOrderInformation(OrderID)
        If ds.Tables.Count < 1 Then
        ElseIf ds.Tables(0).Rows.Count > 0 Then
            dr = ds.Tables(0).Rows(0)
        End If
        DivisionID = CInt(dr("DivisionID"))
        hdnDivisionID.Value = DivisionID
        ShowAbbreviation = CStr(dr("ShowAbbreviation"))
        sb = New StringBuilder(ShowAbbreviation)
        sb.Append(" - ")
        sb.Append(CStr(dr("ShowName")))
        ShowName = sb.ToString
        lblShowName.Text = ShowName
        DealerNumber = CType(dr("DealerNumber"), Int64)
        lblDealerNumber.Text = CStr(DealerNumber)
        DealerName = CStr(dr("DealerName"))
        lblDealerName.Text = DealerName
    End Sub

    Protected Sub rgItems_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rgItems.ItemDataBound
        Dim OrderControl As UserControl = Nothing
        Dim hDivisionID, hDealerNumber As HiddenField
        If TypeOf e.Item Is GridEditFormItem _
            AndAlso e.Item.IsInEditMode Then
            OrderControl = CType(e.Item.FindControl(GridEditFormItem.EditFormUserControlID), UserControl)
            hDivisionID = DirectCast(OrderControl.FindControl("hdnDivisionID"), HiddenField)
            hDivisionID.Value = hdnDivisionID.Value
            hDealerNumber = DirectCast(OrderControl.FindControl("HdnDealerNumber"), HiddenField)
            hDealerNumber.Value = lblDealerNumber.Text
        End If
    End Sub

    Protected Sub rgItems_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles rgItems.NeedDataSource
        Dim DivisionID As Integer
        Dim ws As New CommonFunctions
        DivisionID = CInt(hdnDivisionID.Value)
        rgItems.DataSource = ws.GetItems(DivisionID)
        ws = Nothing
    End Sub

    Protected Sub btnReturn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnReturn.Click
        Dim OrderID As Integer
        Dim sb As StringBuilder = Nothing
        OrderID = CInt(hdnOrderID.Value)
        sb = New StringBuilder("OrderItems.aspx")
        sb.Append("?OrderID=")
        sb.Append(OrderID.ToString)
        Response.Redirect(sb.ToString)
    End Sub
End Class

the user control
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="OrderItem.ascx.vb" Inherits="OrderItem" %>
<table border="1" cellpadding="1" cellspacing="1" style="background-color:#FFCC99;">
<tr>
<td>
    <asp:HiddenField ID="hdnDivisionID" runat="server" />
</td>
<td>
    <asp:HiddenField ID="hdnDealerNumber" runat="server" />
</td>
</tr>
<tr>
<td>ItemID</td>
<td>
    <asp:Label ID="lblItemID" Text='<%# DataBinder.Eval( Container, "DataItem.ItemID") %>' runat="server" />
</td>
</tr>
<tr>
<td>LNS Part Number</td>
<td>
    <asp:Label ID="lblLNSPartNo" Text='<%# DataBinder.Eval( Container, "DataItem.LNSPartNo") %>' runat="server" />
</td>
</tr>
<tr>
<td>KMS Part Number</td>
<td>
    <asp:Label ID="lblKMSPartNo" Text='<%# DataBinder.Eval( Container, "DataItem.KMSPartNo") %>' runat="server" />
</td>
</tr>
<tr>
<td>Description</td>
<td>
    <asp:Label ID="lblDescription" Text='<%# DataBinder.Eval(Container, "DataItem.Description") %>' runat="server" />
</td>
</tr>
<tr>
<td>Net Cost</td>
<td>
    <telerik:RadNumericTextBox ID="rntbNetCost" runat="server">
    </telerik:RadNumericTextBox>
</td>
</tr>
<tr>
<td>Cost Source</td>
<td>
    <asp:Label ID="lblCostSource" runat="server" />
    <asp:HiddenField ID="hdnCostSource" runat="server" />
    <asp:HiddenField ID="hdnNetCost" runat="server" />
</td>
</tr>
<tr>
<td>Quantity</td>
<td>
    <telerik:RadNumericTextBox ID="rntbQuantity" DataType="System.Integer" NumberFormat-DecimalDigits="0" runat="server">
    </telerik:RadNumericTextBox>
    <asp:RequiredFieldValidator ID="rfvQuantity" ControlToValidate="rntbQuantity" ErrorMessage="Quantity Required" runat="server" />
</td>
</tr>
<tr>
<td>
    <asp:Button ID="btnAddtoOrder" Text="Add to Order" CommandName="AddtoOrder" runat="server" />
</td>
<td align="right">
    <asp:Button ID="btnCancel" Text="Cancel" CommandName="Cancel" CausesValidation="false" runat="server" />
</td>
</tr>
</table>
and its code behind
Imports System.Data

Partial Class OrderItem
    Inherits System.Web.UI.UserControl

    Private _dataItem As Object
    Public Property DataItem() As Object
        Get
            Return Me._dataItem
        End Get
        Set(ByVal value As Object)
            Me._dataItem = value
        End Set
    End Property

    Protected Sub Page_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.DataBinding
        Dim dItem As Object = DataItem
        Dim SpringInvPrice, SpringTenTerms, ShowInvPrice, ShowTenTerms, NetCost As Double

        SpringInvPrice = CType(DataBinder.Eval(DataItem, "SpringInvPrice"), Double)
        SpringTenTerms = CType(DataBinder.Eval(DataItem, "SpringTenTerms"), Double)
        ShowInvPrice = CType(DataBinder.Eval(DataItem, "ShowInvPrice"), Double)
        ShowTenTerms = CType(DataBinder.Eval(DataItem, "ShowTenTerms"), Double)
        If ShowTenTerms > 0 Then
            NetCost = ShowTenTerms
            hdnCostSource.Value = 4
            lblCostSource.Text = "Show Only Net Terms"
        ElseIf ShowInvPrice > 0 Then
            NetCost = ShowInvPrice
            hdnCostSource.Value = 3
            lblCostSource.Text = "Show Only Net Invoice"
        ElseIf SpringTenTerms > 0 Then
            NetCost = SpringTenTerms
            hdnCostSource.Value = 2
            lblCostSource.Text = "Spring Dating Net Terms"
        ElseIf SpringTenTerms > 0 Then
            NetCost = SpringInvPrice
            hdnCostSource.Value = 1
            lblCostSource.Text = "Spring Dating Net Invoice"
        Else
            NetCost = 0
            hdnCostSource.Value = 6
            lblCostSource.Text = "Unknown/Unspecified"
        End If
        rntbNetCost.Value = NetCost
        hdnNetCost.Value = NetCost
    End Sub

    Protected Sub btnAddtoOrder_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAddtoOrder.Click
        Dim OrderID, DivisionID, ItemID, Qty, OrderItemID, CostSource As Integer
        Dim DealerNumber As Int64
        Dim LNSPartNo, KMSPartNo As String
        Dim NetCost As Double = 0

        If Page.IsValid Then
        Else
            Exit Sub
        End If
        DivisionID = CInt(hdnDivisionID.Value)
        DealerNumber = CType(hdnDealerNumber.Value, Int64)
        Dim ws As New CommonFunctions
        OrderID = ws.GetOrderID(DealerNumber, DivisionID)
        ItemID = CInt(lblItemID.Text)
        LNSPartNo = CStr(lblLNSPartNo.Text.Trim())
        KMSPartNo = CStr(lblKMSPartNo.Text.Trim())
        Qty = rntbQuantity.Value
        NetCost = rntbNetCost.Value
        If NetCost = CType(hdnNetCost.Value, Double) Then
            CostSource = CInt(hdnCostSource.Value)
        Else
            CostSource = 5
        End If
        OrderItemID = ws.InsertOrderItem(OrderID, ItemID, String.Empty, Qty, _
            NetCost, CostSource)
        ws = Nothing
    End Sub
End Class

how do I get the user control to close when it's done adding an item to the order?









Elliott
Top achievements
Rank 2
 answered on 28 Jul 2010
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?