Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
226 views
I have a RadGrid with one Details table.  I have code-behind (ItemDataBound) that sets column colors based on data from the database.  Works great.

When expanding a Details table in any one row, the color styling in the Main table disappears.

Please see attached for a visual example.


--- Markup:
<%@ Page Title="Home Page" Language="vb" MasterPageFile="~/Site.Master" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="NPI2._Default" EnableEventValidation="true" %>
<%@ MasterType virtualpath="~/Site.Master" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
    <title>NPI</title>
    <script src="~/Scripts/tooltip.js" type="text/javascript"></script>
    <link href="Styles/NPI2.css" rel="stylesheet" type="text/css" />
    <link href="Styles/LogicPD.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <asp:Label ID="lbl_Error" runat="server" Text="" Font-Size="11px"></asp:Label>
    <asp:HiddenField runat="server" ID="hid_custKey" />

    <div style="display:block; width:100%; height:auto;">
        <table width="100%" border="0" style="margin-bottom:20px;">
            <tr>
                <td class="npi_toptd1">
                    <div style="display:inline; float:left;">
                        View&nbsp;Archived:&nbsp;&nbsp;
                        <asp:CheckBox runat="server" ID="cbx_Archive" AutoPostBack="true" />
                    </div>
                    <asp:HiddenField runat="server" ID="hid_ArchCBox" Value="0" /></td>
                <td class="npi_toptd1">
                    View&nbsp;By&nbsp;Customer:&nbsp;&nbsp;
                    <telerik:RadDropDownList ID="RadDropDownList_Customers" runat="server" DataValueField="CustomerKey" DataTextField="CustomerName" AutoPostBack="true">
                    </telerik:RadDropDownList>
                </td>
                <td class="npi_toptd2">
                    <asp:Button runat="server" ID="btnNewProduct" Text="Add New Product" Enabled="false" />
                </td>
                <td class="npi_toptd2">
                    <input runat="server" type="button" id="btnNewCustomerRedirect" value="Add New Customer" display="false" onclick="redirCustomer('AddCustomer.aspx');" />
                </td>
            </tr>
        </table>


        
        <div style="float:left; height:90%; width:100%; overflow:auto;">

            <telerik:RadGrid ID="RadGrid_Main" runat="server"
                DataSourceID="Sql_Data_MainTable"
                AllowMultiRowSelection="false"
                AllowPaging="True"
                AlternatingItemStyle-BackColor="ControlLight"
                AutoGenerateColumns="False"
                AutoGenerateDeleteColumn="True"
                AutoGenerateEditColumn="True"
                CellSpacing="0"
                GridLines="None"
                GroupPanelPosition="Top"
                Height="600px"
                PageSize="500">
                <ClientSettings EnablePostBackOnRowClick="false" AllowDragToGroup="False" AllowGroupExpandCollapse="True">
                    <Scrolling AllowScroll="False" UseStaticHeaders="True" />
                    <Selecting AllowRowSelect="false" />
                </ClientSettings>
                <FilterMenu EnableImageSprites="False"></FilterMenu>
                <HeaderStyle Font-Bold="True" />
                <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
                <MasterTableView
                    CommandItemDisplay="Top"
                    DataKeyNames="ProductKey"
                    DataSourceID="Sql_Data_MainTable"
                    EditMode="EditForms"
                    Name="NPI_MasterTable">
                    <EditFormSettings>
                        <EditColumn ButtonType="PushButton"></EditColumn>
                    </EditFormSettings>
                    <ExpandCollapseColumn Visible="True" HeaderStyle-Width="20px"></ExpandCollapseColumn>
                    <CommandItemSettings ShowAddNewRecordButton="true" AddNewRecordText="Add New Item"></CommandItemSettings>
                    <RowIndicatorColumn Visible="True" HeaderStyle-Width="20px"></RowIndicatorColumn>
                    <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
                    <Columns>
                        <telerik:GridNumericColumn DataField="ProductKey" DecimalDigits="5" Display="False" HeaderText="ProductKey" UniqueName="ProductKey" ReadOnly="true"></telerik:GridNumericColumn>

                        <telerik:GridTemplateColumn HeaderText="Assembly Part Number" UniqueName="TemplateColumn_ItemID">
                            <HeaderStyle Width="150" Wrap="false" Font-Size="10px" />
                            <ItemStyle Font-Size="11px" />
                            <ItemTemplate>
                                <asp:Label ID="lbl_ItemID" runat="server" Text='<%# Eval("ItemID")%>' />
                                <br />
                                <asp:CheckBox id="cbx_PW" runat="server" Checked='<%# Eval("PacketWaiting") %>' Enabled="false"></asp:CheckBox>&nbsp;PW
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:Textbox ID="txt_ItemID" runat="server" Text='<%# Bind("ItemID")%>' ReadOnly="false" />
                                <br />
                                <asp:CheckBox id="cbx_PW" runat="server" Checked='<%# Bind("PacketWaiting") %>' Enabled="true"></asp:CheckBox>&nbsp;PW
                                <br />
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:Textbox ID="txt_ItemID" runat="server" Text='' ReadOnly="false" />
                                <asp:RequiredFieldValidator ID="req1" runat="server" ErrorMessage="* Required" ControlToValidate="txt_ItemID" CssClass="Error tdRed"></asp:RequiredFieldValidator>
                                <br />
                                <asp:CheckBox id="cbx_PW" runat="server" Checked='false' Enabled="true"></asp:CheckBox>&nbsp;PW
                                <br />
                            </InsertItemTemplate>
                        </telerik:GridTemplateColumn>

                        <telerik:GridBoundColumn DataField="AssemblyRev" HeaderText="Assy Revision" UniqueName="AssyRev">
                            <HeaderStyle Width="50" Font-Size="10px" />
                            <ItemStyle Font-Size="11px" />
                            <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                <RequiredFieldValidator ErrorMessage="&nbsp;* Required" CssClass="Error tdRed"></RequiredFieldValidator>
                            </ColumnValidationSettings>
                        </telerik:GridBoundColumn>

                        <telerik:GridDropDownColumn DataField="CustomerKey" DataSourceID="Sql_Data_Customers" HeaderText="Customer" ListTextField="CustomerName" ListValueField="CustomerKey" UniqueName="ddCustomer">
                            <HeaderStyle Width="130" Font-Size="10px" />
                            <ItemStyle Font-Size="11px" />
                            <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                <RequiredFieldValidator ErrorMessage="&nbsp;* Required" CssClass="Error tdRed"></RequiredFieldValidator>
                            </ColumnValidationSettings>
                        </telerik:GridDropDownColumn>

                        
                        <telerik:GridTemplateColumn HeaderText="Expected<br />Start Date" UniqueName="StartDate">
                            <HeaderStyle Width="60" Font-Size="10px" />
                            <ItemStyle Font-Size="11px" />
                            <ItemTemplate>
                                <asp:Label runat="server" ID="lbl_StartDate" Text='<%# Eval("StartDate2")%>' />
                            </ItemTemplate>
                            <EditItemTemplate>
                                <telerik:RadDatePicker ID="dateP_StartDate" runat="server" SelectedDate='<%# CType(Eval("StartDate2"), Date)%>'></telerik:RadDatePicker>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <telerik:RadDatePicker ID="dateP_StartDate" runat="server"></telerik:RadDatePicker>
                                <asp:RequiredFieldValidator ID="req2" runat="server" ErrorMessage="* Required" ControlToValidate="dateP_StartDate" CssClass="Error"></asp:RequiredFieldValidator>
                            </InsertItemTemplate>
                        </telerik:GridTemplateColumn>
                        
                        <telerik:GridDropDownColumn DataField="Status" DataSourceID="Sql_Data_Types" HeaderText="Type" ListTextField="Type" ListValueField="TypeKey" UniqueName="Type">
                            <HeaderStyle Width="110" HorizontalAlign="Center" Font-Size="10px" />
                            <ItemStyle Font-Size="11px" />
                            <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                <RequiredFieldValidator ErrorMessage="&nbsp;* Required" CssClass="Error tdRed"></RequiredFieldValidator>
                            </ColumnValidationSettings>
                        </telerik:GridDropDownColumn>
                        
                        <telerik:GridTemplateColumn HeaderText="Expected<br />Ship Date" UniqueName="ShipDate">
                            <HeaderStyle Width="60" Font-Size="10px" />
                            <ItemStyle Font-Size="11px" />
                            <ItemTemplate>
                                <asp:Label runat="server" ID="lbl_ShipDate" Text='<%# Eval("ShipDate")%>' />
                            </ItemTemplate>
                            <EditItemTemplate>
                                <telerik:RadDatePicker ID="dateP_ShipDate" runat="server" SelectedDate='<%# CType(Eval("ShipDate"), Date)%>'></telerik:RadDatePicker>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <telerik:RadDatePicker ID="dateP_ShipDate" runat="server"></telerik:RadDatePicker>
                                <asp:RequiredFieldValidator ID="req3" runat="server" ErrorMessage="* Required" ControlToValidate="dateP_ShipDate" CssClass="Error"></asp:RequiredFieldValidator>
                            </InsertItemTemplate>
                        </telerik:GridTemplateColumn>
                        
                        <telerik:GridBoundColumn DataField="ECONum" HeaderText="ECO<br />Number" UniqueName="ECONumber">
                            <HeaderStyle Width="80" Font-Size="10px" />
                            <ItemStyle Font-Size="11px" />
                        </telerik:GridBoundColumn>

                        <telerik:GridBoundColumn DataField="PO_JobNumber" HeaderText="PO/<br />Job Number" UniqueName="POJob">
                            <HeaderStyle Width="80" Font-Size="10px" />
                            <ItemStyle Font-Size="11px" />
                        </telerik:GridBoundColumn>

                        <telerik:GridDropDownColumn DataField="CustomerFocusEng" DataSourceID="Sql_Data_CFEng" HeaderText="Customer Focus<br />Engineer" ListTextField="EngineerName" ListValueField="CustomerFocusEngKey" UniqueName="ddCFEng">
                            <HeaderStyle Width="100" Font-Size="10px" />
                            <ItemStyle Font-Size="11px" />
                            <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                <RequiredFieldValidator ErrorMessage="&nbsp;* Required" CssClass="Error tdRed"></RequiredFieldValidator>
                            </ColumnValidationSettings>
                        </telerik:GridDropDownColumn>

                        <telerik:GridBoundColumn DataField="CommentsFull" HeaderText="Comments" UniqueName="CommentsFull" Display="false"></telerik:GridBoundColumn>

                        <telerik:GridBoundColumn DataField="Comments" HeaderText="Comments..." UniqueName="Comments" ReadOnly="true">
                            <HeaderStyle Width="150" Font-Size="10px" />
                            <ItemStyle Font-Size="11px" />
                        </telerik:GridBoundColumn>

                        <telerik:GridDropDownColumn DataField="PasteStencils" DataSourceID="Sql_Data_Stati" ListTextField="Status" ListValueField="StatusKey" HeaderText="Stencil" UniqueName="PasteStencils">
                            <HeaderStyle Width="5" HorizontalAlign="Center" Font-Size="9px" />
                            <ItemStyle Font-Size="2px" />
                            <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                <RequiredFieldValidator ErrorMessage="&nbsp;* Required" CssClass="Error tdRed"></RequiredFieldValidator>
                            </ColumnValidationSettings>
                        </telerik:GridDropDownColumn>

                        <telerik:GridDropDownColumn DataField="SideSMT" DataSourceID="Sql_Data_Stati" ListTextField="Status" ListValueField="StatusKey" HeaderText="SMT" UniqueName="SMT">
                            <HeaderStyle Width="5" HorizontalAlign="Center" Font-Size="10px" /> 
                            <ItemStyle Font-Size="2px" />                           
                            <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                <RequiredFieldValidator ErrorMessage="&nbsp;* Required" CssClass="Error tdRed"></RequiredFieldValidator>
                            </ColumnValidationSettings>
                        </telerik:GridDropDownColumn>

                        <telerik:GridDropDownColumn DataField="Approval" DataSourceID="Sql_Data_Approval" HeaderText="Approval" ListTextField="ApprovalStatus" ListValueField="ApprovalKey" UniqueName="ddApproval">
                            <HeaderStyle Width="65" Font-Size="10px" />
                            <ItemStyle Font-Size="11px" />
                            <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                <RequiredFieldValidator ErrorMessage="&nbsp;* Required" CssClass="Error tdRed"></RequiredFieldValidator>
                            </ColumnValidationSettings>
                        </telerik:GridDropDownColumn>

                    </Columns>

                    <DetailTables>
                        <telerik:GridTableView Name="NPI_DetailsTable_Admin" runat="server"
                            DataSourceID="Sql_Data_DetailTable"
                            AllowAutomaticInserts="False"
                            AllowPaging="False"
                            AlternatingItemStyle-BackColor="#F7EED7"
                            AutoGenerateColumns="false"
                            CommandItemDisplay="Top"
                            DataKeyNames="ProductKey"
                            EditMode="PopUp"
                            EnableHeaderContextMenu="True"
                            GroupsDefaultExpanded="True" 
                            GroupLoadMode="Client"
                            HeaderStyle-ForeColor="#873F00"
                            HeaderStyle-Font-Bold="true"
                            ItemStyle-BackColor="#FAE5B4"
                            Width="100%">
                            <EditFormSettings>
                                <EditColumn FilterControlAltText="Filter EditCommandColumn column" ButtonType="PushButton"></EditColumn>
                            </EditFormSettings>
                            <ParentTableRelation>
                                <telerik:GridRelationFields DetailKeyField="ProductKey" MasterKeyField="ProductKey" />
                            </ParentTableRelation>
                            <CommandItemSettings ShowAddNewRecordButton="false" ShowRefreshButton="true" />
                            <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" Visible="True" HeaderStyle-Width="20px" />
                            <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True" HeaderStyle-Width="20px" />
                            <Columns>
                                <telerik:GridNumericColumn DataField="ProductKey" DecimalDigits="0" Display="False" HeaderText="ProductKey" UniqueName="ProductKey" ReadOnly="true"></telerik:GridNumericColumn>
                                <telerik:GridNumericColumn DataField="CategoryKey" DecimalDigits="0" Display="False" HeaderText="CategoryKey" UniqueName="CategoryKey" ReadOnly="true"></telerik:GridNumericColumn>
                                <telerik:GridBoundColumn DataField="Category" HeaderText="Category" UniqueName="Category" ReadOnly="true"></telerik:GridBoundColumn>
                                
                                <telerik:GridBoundColumn DataField="RoHS_Color" HeaderText="RoHS_Color" UniqueName="RoHS_Color" ReadOnly="true" Display="false"></telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="RoHS_opt" HeaderText="RoHS_opt" UniqueName="RoHS_opt" ReadOnly="true" Display="false"></telerik:GridBoundColumn>
                                <telerik:GridTemplateColumn HeaderText="RoHS<br />Requirements" UniqueName="RoHS">
                                    <HeaderStyle Width="60" Font-Size="10px" />
                                    <ItemStyle Font-Size="11px" />
                                    <ItemTemplate>
                                        <asp:Label runat="server" ID="lbl_User" Text='<%# Eval("RoHS_User")%>' /><br />
                                        <asp:Label runat="server" ID="lbl_Option" Text='<%# Eval("RoHS_opt")%>' />
                                        <asp:HiddenField runat="server" ID="hid_Color_RoHS" Value='<%# Eval("RoHS_Color")%>' />
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                            </Columns>
                        </telerik:GridTableView>
                    </DetailTables>
                </MasterTableView>
            </telerik:RadGrid>


            <%'Data Sources %>
            <asp:SqlDataSource ID="Sql_Data_MainTable" runat="server" SelectCommand="npi.GetNPIData_MainTable" SelectCommandType="StoredProcedure">
                <SelectParameters>
                    <asp:ControlParameter ControlID="cbx_Archive" DefaultValue="0" Name="seeArchived" PropertyName="Checked" Type="Boolean" />
                    <asp:ControlParameter ControlID="RadDropDownList_Customers" DefaultValue="1" Name="custKey" PropertyName="SelectedValue" Type="Int32" />
                </SelectParameters>
            </asp:SqlDataSource>
            <asp:SqlDataSource ID="Sql_Data_Customers" runat="server" SelectCommand="npi.GetCustomersAll" SelectCommandType="StoredProcedure" ProviderName="System.Data.SqlClient"></asp:SqlDataSource>
            <asp:SqlDataSource ID="Sql_Data_Types" runat="server" SelectCommand="npi.GetType" SelectCommandType="StoredProcedure" ProviderName="System.Data.SqlClient"></asp:SqlDataSource>
            <asp:SqlDataSource ID="Sql_Data_CFEng" runat="server" SelectCommand="npi.GetCustomerFocusEng" SelectCommandType="StoredProcedure" ProviderName="System.Data.SqlClient"></asp:SqlDataSource>
            <asp:SqlDataSource ID="Sql_Data_Approval" runat="server" SelectCommand="npi.GetApproval" SelectCommandType="StoredProcedure" ProviderName="System.Data.SqlClient"></asp:SqlDataSource>
            <asp:SqlDataSource ID="Sql_Data_Stati" runat="server" SelectCommand="npi.GetNPIStati" SelectCommandType="StoredProcedure" ProviderName="System.Data.SqlClient"></asp:SqlDataSource>
            
            <asp:SqlDataSource ID="Sql_Data_DetailTable" runat="server" SelectCommand="npi.GetNPIData_DetailTable" SelectCommandType="StoredProcedure" ProviderName="System.Data.SqlClient">
                <SelectParameters>
                    <asp:ControlParameter ControlID="RadGrid_Main" Name="ProductKey" PropertyName="SelectedValue" Type="Int64" />
                </SelectParameters>
            </asp:SqlDataSource>
        </div>
        <br />
        <div style="float:right">
            <table style="width:320px; float:right; border:1px solid black; font-size:x-small; margin-top:20px;">
                <tr>
                    <td style="background-color: #88DD88; text-align:center;">Complete or Not Required</td>
                    <td style="background-color: #FFFFAA; text-align:center;">In Process</td>
                    <td style="background-color: #FFAAAA; text-align:center;">Hold/Not Started</td>
                </tr>
            </table>
        </div>


    </div>
</asp:Content>


--- Code-behind:


Imports System.Environment
Imports System.Web.UI.WebControls.LoginName
Imports System
Imports System.Collections
Imports System.Collections.Generic
Imports System.Data
Imports System.Data.SqlClient
Imports System.Text
Imports System.Text.RegularExpressions
Imports NPI2.DBAccess
Imports Telerik.Web.UI
Imports ACME_Utilities
Imports Outlook = Microsoft.Office.Interop.Outlook
Imports System.DirectoryServices

Public Class _Default
    Inherits System.Web.UI.Page

#Region "variables"
    Dim connStr As String
    Dim Environ As String
    Dim DAccess As New DBAccess
    Dim Comments_ProductID As String    'for use with Comments (productID)
    Dim prodID As String
    Dim colID As String
    Dim newProductInd As String
    Dim headerDS As New DataSet
    Dim modal3DS As New DataSet
    Dim selectedColor As String
    Dim changeInd As Boolean
    Dim includeArchive As Boolean
    Public archInd As String
    Dim sort As String
    Dim order As String
    Dim order2 As String
    Dim table2id As Int64
    Public commentKey As Int32
    Public tblb As String
    Public CustomerKey As Int32
    Public category As String
    Public userName As String
    Public RowProductKey As Int64

    Dim UpdateIndicator As Boolean
    Dim strReturnValue As String
#End Region

    Private Sub Page_Init(sender As Object, e As System.EventArgs) Handles Me.Init
        Try
            If InStr(Request.Url.ToString(), "appserver") > 0 Then Environ = "prod" Else Environ = "dev"
            connStr = System.Configuration.ConfigurationManager.ConnectionStrings(Environ).ConnectionString
            Sql_Data_Approval.ConnectionString = connStr
            Sql_Data_CFEng.ConnectionString = connStr
            Sql_Data_Customers.ConnectionString = connStr
            Sql_Data_MainTable.ConnectionString = connStr
            Sql_Data_Types.ConnectionString = connStr
            Sql_Data_DetailTable.ConnectionString = connStr
        Catch ex As Exception
            ErrorLog_Write("NPI - Default.aspx", ex.Message, "PageInit")
        End Try
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            Sql_Data_MainTable.ConnectionString = connStr
            Sql_Data_Customers.ConnectionString = connStr
            Sql_Data_Types.ConnectionString = connStr
            Sql_Data_CFEng.ConnectionString = connStr
            Sql_Data_Approval.ConnectionString = connStr
            Sql_Data_Stati.ConnectionString = connStr

            lbl_Error.Text = ""
            lbl_Error.Visible = False
            lbl_Error.ForeColor = Drawing.Color.Black
            lbl_Error.BackColor = Drawing.Color.Transparent

            hid_custKey.Value = RadDropDownList_Customers.SelectedValue
            hid_ArchCBox.Value = IIf(cbx_Archive.Checked, 1, 0)

            userName = Master.LoginName()
            If userName = "" Then userName = Context.User.Identity.Name.Replace("ACME\", "")
            If userName = "" Then userName = HttpContext.Current.Request.LogonUserIdentity.Name.ToString.Split("\"c)(1)
            If userName = "" Then userName = "uknown"

            GetCustomersForDropDownList()

            If IsPostBack Then
                'RadGrid_Main.Rebind()
                'RadGrid_Main.MasterTableView.ClearEditItems()   'Closes the Edit window, if it is open
            End If

        Catch ex As Exception
            ErrorLog_Write("NPI - Default.aspx", ex.Message, "PageLoad")
        End Try
    End Sub

    
    Protected Sub GetCustomersForDropDownList()
        Try
            Dim dsC As New DataSet
            dsC = DBAccess.GetSPData("npi.Customers_Get_Active", "PopulateCustomerDropDown", connStr)
            RadDropDownList_Customers.DataSource = dsC.Tables(0)
            RadDropDownList_Customers.DataBind()

            'Modal:
            'RadDropDownList_Customers.DataSource = dsC.Tables(0)
            'RadDropDownList_Customers.DataBind()
        Catch ex As Exception
            ErrorLog_Write("NPI - Default.aspx", ex.Message, "RadGrid_MainTable_ItemDataBound")
        End Try
    End Sub



#Region "RadGrid_Main construction"
    Private Sub RadGrid_Main_ItemCommand(sender As Object, e As GridCommandEventArgs) Handles RadGrid_Main.ItemCommand
        If e.CommandName = RadGrid.InitInsertCommandName Then
            e.Canceled = True
            'Prepare an IDictionary with the predefined values
            Dim newValues As New System.Collections.Specialized.ListDictionary
            'set initial checked state for the checkbox on init insert  
            newValues("cbx_PW") = False
            'Insert the item and rebind  
            e.Item.OwnerTableView.InsertItem(newValues)
        End If
    End Sub

    Private Sub radGrid_Main_ItemCreated(sender As Object, e As GridItemEventArgs) Handles RadGrid_Main.ItemCreated
        Try
            If TypeOf e.Item Is GridDataItem Then
                Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
                Dim deleteBtn As LinkButton = DirectCast(item.FindControl("AutoGeneratedDeleteButton"), LinkButton)
                deleteBtn.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this row?')")
            End If

            If (TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode) Then
                Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)

                Dim txBx As TextBox = CType(editedItem("CommentsFull").Controls.Item(0), TextBox)
                txBx.Width = 500
                txBx.Height = 75
                txBx.TextMode = TextBoxMode.MultiLine
            End If

            If TypeOf e.Item Is GridCommandItem Then
                Dim commandItem As GridCommandItem = CType(e.Item, GridCommandItem)
                commandItem.Width = 30
            End If

        Catch ex As Exception
            ErrorLog_Write("NPI - Default.aspx", ex.Message, "radGrid_Main_ItemCreated")
        End Try
    End Sub

    Private Sub RadGrid_Main_ItemDataBound(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid_Main.ItemDataBound
        If (TypeOf e.Item Is GridDataItem) Then
            Dim dataBoundItem As GridDataItem = CType(e.Item, GridDataItem)

            If e.Item.OwnerTableView.Name = "NPI_MasterTable" Then
                If dataBoundItem("Comments").Text = "..." Then
                    dataBoundItem("Comments").Text = ""
                    dataBoundItem("Comments").ToolTip = ""
                Else
                    dataBoundItem("Comments").ToolTip = dataBoundItem("CommentsFull").Text
                End If
'Coloration: Main table
                If dataBoundItem("Type").Text = "Box Build" Then
                    dataBoundItem("Type").BackColor = Drawing.Color.FromName("#ffaaaa")
                ElseIf dataBoundItem("Type").Text = "Kit" Then
                    dataBoundItem("Type").BackColor = Drawing.Color.FromName("#77aaff")
                ElseIf dataBoundItem("Type").Text = "New Assy" Then
                    dataBoundItem("Type").BackColor = Drawing.Color.FromName("#ffffaa")
                ElseIf dataBoundItem("Type").Text = "NwAssy/ExstngPCB" Then
                    dataBoundItem("Type").BackColor = Drawing.Color.FromName("#88dd88")
                ElseIf dataBoundItem("Type").Text = "ECO" Then
                    dataBoundItem("Type").BackColor = Drawing.Color.FromName("#C0C0C0")
                ElseIf dataBoundItem("Type").Text = "PMONPI" Then
                    dataBoundItem("Type").BackColor = Drawing.Color.FromName("#DBE7FF")
                ElseIf dataBoundItem("Type").Text = "ECO-New Pwb" Then
                    dataBoundItem("Type").BackColor = Drawing.Color.FromName("#FFE3AD")
                ElseIf dataBoundItem("Type").Text = "Machine Transfer" Then
                    dataBoundItem("Type").BackColor = Drawing.Color.FromName("#DBBC97")
                ElseIf dataBoundItem("Type").Text = "WC Transfer" Then
                    dataBoundItem("Type").BackColor = Drawing.Color.FromName("#C69DED")
                End If

                If dataBoundItem("PasteStencils").Text = "Hold/Not Started" Then
                    dataBoundItem("PasteStencils").ForeColor = Drawing.Color.FromName("#ffaaaa")
                    dataBoundItem("PasteStencils").BackColor = Drawing.Color.FromName("#ffaaaa")
                ElseIf dataBoundItem("PasteStencils").Text = "In Process" Then
                    dataBoundItem("PasteStencils").ForeColor = Drawing.Color.FromName("#ffffaa")
                    dataBoundItem("PasteStencils").BackColor = Drawing.Color.FromName("#ffffaa")
                Else
                    dataBoundItem("PasteStencils").ForeColor = Drawing.Color.FromName("#88dd88")
                    dataBoundItem("PasteStencils").BackColor = Drawing.Color.FromName("#88dd88")
                End If

                If dataBoundItem("SMT").Text = "Hold/Not Started" Then
                    dataBoundItem("SMT").ForeColor = Drawing.Color.FromName("#ffaaaa")
                    dataBoundItem("SMT").BackColor = Drawing.Color.FromName("#ffaaaa")
                ElseIf dataBoundItem("SMT").Text = "In Process" Then
                    dataBoundItem("SMT").ForeColor = Drawing.Color.FromName("#ffffaa")
                    dataBoundItem("SMT").BackColor = Drawing.Color.FromName("#ffffaa")
                Else
                    dataBoundItem("SMT").ForeColor = Drawing.Color.FromName("#88dd88")
                    dataBoundItem("SMT").BackColor = Drawing.Color.FromName("#88dd88")
                End If

                If dataBoundItem("ddCFEng").Text = "&nbsp;" Then dataBoundItem("ddCFEng").Text = "Select..."
            ElseIf e.Item.OwnerTableView.Name = "NPI_DetailsTable_Admin" Then
                Dim nestedTableView As GridTableView = CType(RadGrid_Main.MasterTableView.Items(0), GridDataItem).ChildItem.NestedTableViews(0) 'not used yet

'Coloration: details table
                If dataBoundItem("RoHS_Color").Text = "2" Then
                    dataBoundItem("RoHS").BackColor = Drawing.Color.FromName("#FFFFAA")
                ElseIf dataBoundItem("RoHS_Color").Text = "3" Then
                    dataBoundItem("RoHS").BackColor = Drawing.Color.FromName("#FFAAAA")
                Else
                    dataBoundItem("RoHS").BackColor = Drawing.Color.FromName("#88DD88")
                End If

                Dim _lbl_RoHS_opt As Label = CType(dataBoundItem("RoHS").FindControl("lbl_Option"), Label)
                If dataBoundItem("RoHS_opt").Text = "0" Then
                    _lbl_RoHS_opt.Text = "No"
                Else
                    _lbl_RoHS_opt.Text = "Yes"
                End If
            End If

        End If
    End Sub


#End Region



#Region "Command Events"
    'Insert into Main Table
    Private Sub RadGrid_Main_InsertCommand(sender As Object, e As GridCommandEventArgs) Handles RadGrid_Main.InsertCommand
        Try
            If e.Item.OwnerTableView.Name = "NPI_MasterTable" Then
                'Insert code
            End If
        Catch ex As Exception
            ErrorLog_Write("NPI - Default.aspx", ex.Message, "RadGrid_Main_InsertCommand")
        End Try
    End Sub

    'Update Main Table item
    Private Sub RadGrid_Main_UpdateCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid_Main.UpdateCommand
        Try
            If e.Item.OwnerTableView.Name = "NPI_MasterTable" Then
                'Update Code
            End If
        Catch ex As Exception
            ErrorLog_Write("NPI - Default.aspx", ex.Message, "RadGrid_Main_UpdateCommand")
        End Try
    End Sub

    'Delete from Main Table
    Private Sub RadGrid_Main_DeleteCommand(sender As Object, e As GridCommandEventArgs) Handles RadGrid_Main.DeleteCommand
        Try
            If e.Item.OwnerTableView.Name = "NPI_MasterTable" Then
                'Delete Code
            End If
        Catch ex As Exception
            ErrorLog_Write("NPI - Default.aspx", ex.Message, "RadGrid_Main_DeleteCommand")
        End Try
    End Sub
#End Region



#Region "Error Handling"
    'Write Errors to the database
    Public Sub ErrorLog_Write(ByVal page, ByVal exMessage, ByVal Err2)
        Try
            'Error handling
        Catch ex As Exception
            lbl_Error.Text = "There was an error writing to the Error Log.<br />The error was not saved.<br /><br />(Page: " + page + ")"
        End Try
    End Sub
#End Region
End Class






Chris
Top achievements
Rank 1
 answered on 06 Apr 2015
3 answers
281 views

Hi,

How to refresh the wizard from an event inside a usercontrol that forms part of the steps.

So for example, If I have a usercontrol inside step one and when a 'save button' in clicked in this user control, how to pass that to the wizard and change step visibility, icons etc. 

Cheers,

Jack

Jon
Top achievements
Rank 1
 answered on 06 Apr 2015
5 answers
131 views
Hi,

I know this is probably something really simple, but I can't get it to work. I'm trying to add icons to the HeaderTemplate and make them right justified. I used span and div tags but they seem to push the icons down into the content area.

Here's my asp page:

<head id="Head1" runat="server">
    <title></title>
    <link href="CustomSkin/PanelBar.Salt.css" rel="stylesheet" />
     
    <style type="text/css">
        .RadPanelBar_Salt a.rpLink.GreenPanel.rpExpandable.rpExpanded {
            background-color: green;
            background-position: 0 -1000px;
            border-color: green;
        }
    </style
     
</head>
<body>
     
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
        <telerik:RadSkinManager ID="RadSkinManager1" runat="server"></telerik:RadSkinManager>
       <%--<telerik:RadButton runat="server" Text="Preview Report" ></telerik:RadButton>--%>
        <telerik:RadPanelBar ID="RadPanelBar1" runat="server"  ExpandMode="MultipleExpandedItems"  Skin="Salt" EnableEmbeddedSkins="false"  >  
            <CollapseAnimation Duration="100" Type="None" /> 
            <Items
                <telerik:RadPanelItem runat="server" Text="Root RadPanelItem1" CssClass="GreenPanel"  >
                    <HeaderTemplate>
                          Root Item 1
                            <asp:ImageButton ID="image1" runat="server"  ImageUrl="~/images/save_go16x16.png" /><asp:ImageButton ID="ImageButton1" runat="server"  ImageUrl="~/images/ie_16x16.png" />
                           <a class="rpExpandable">
                               <span class="rpExpandHandle"></span>
                           </a>
                    </HeaderTemplate>                      
                    <ContentTemplate>
                        <telerik:RadTextBox ID="textbox1" runat="server" Text="text 1"></telerik:RadTextBox>
                        <telerik:RadComboBox runat="server" ID="RadComboBox1" Text="combo1"></telerik:RadComboBox>
                    </ContentTemplate>
                     
                </telerik:RadPanelItem
                <telerik:RadPanelItem runat="server" Text="Root RadPanelItem2" CssClass="GreenPanel" >  
                    <HeaderTemplate>
                        Root Item 2<asp:ImageButton ID="ImageButton2" runat="server"  ImageUrl="~/images/save_go16x16.png"  />
                           <a class="rpExpandable">
                               <span class="rpExpandHandle"></span>
                           </a>
                    </HeaderTemplate>
                    <ContentTemplate>
                        <telerik:RadTextBox ID="RadTextBox1" runat="server" Text="Root Panel 2"></telerik:RadTextBox>
                        <telerik:RadComboBox runat="server" ID="RadComboBox2" Text="combo2"></telerik:RadComboBox>
                    </ContentTemplate>
                </telerik:RadPanelItem
                <telerik:RadPanelItem runat="server" Text="Root RadPanelItem3" CssClass="GreenPanel" >  
                    <HeaderTemplate>
                        Root Item 3<asp:ImageButton ID="ImageButton3" runat="server"  ImageUrl="~/images/save_go16x16.png"  />
                           <a class="rpExpandable">
                               <span class="rpExpandHandle"></span>
                           </a>
                    </HeaderTemplate>
                    <ContentTemplate>
                        <telerik:RadTextBox ID="RadTextBox3" runat="server" Text="Root Panel 3"></telerik:RadTextBox>
                        <telerik:RadComboBox runat="server" ID="RadComboBox3" Text="combo3"></telerik:RadComboBox>
                    </ContentTemplate>
                </telerik:RadPanelItem>
            </Items
            <ExpandAnimation Duration="100" Type="None" /> 
             
        </telerik:RadPanelBar
    </form>
</body>
</html>

I also attached what my screen looks like.

Thank you,

Helen
Magdalena
Telerik team
 answered on 06 Apr 2015
1 answer
151 views
I am using the Radgrid as part of a form in asp.net web forms.

People click on "add new record" button to add a new record, fill out the entire row and then,

instead of clicking on "insert" they just click on the "submit" button at the bottom of the page.


I would like to detect if this has occured, and if it has, I would like the row to be inserted.

How can I accomplish this? 

I have already tried what is below, and it does not work.  If an item is currently being inserted, RadGrid1.Items is still 0.

foreach (GridDataItem item in RadGrid1.Items)
            {
                //Set the Name property for the Detail table 
                if(item.IsInEditMode)
                {
                    var x = "here";
                }
            } 
Viktor Tachev
Telerik team
 answered on 06 Apr 2015
13 answers
824 views
Hi there,

I need to buid a survey interface and thought that RadGrid could be a good candidate for it.
I have two datasources:
1. with questions, with related key;
2. answers, which has a reference to the question key.

Idea is that I would have a radgrid with two columns:
1. Question as bound coulmn
2. RadioButtonList with answers.

The problem is that I can not get two datasources marry by the question key. When I pass a parameter to answers datasource as a control radgrid SelectedValue, the second column is not showing up at all. Any recommendations would be appreciated. I paste my code below.

Thanks,
Yuriy

 

<telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="0" DataSourceID="sqlManufacturerSurvey" 
GridLines="None" AutoGenerateColumns="False"
<MasterTableView DataSourceID="sqlManufacturerSurvey" DataKeyNames="QuestionID" Name="Questions" 
HierarchyLoadMode="Client"
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings
<RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column"
<HeaderStyle Width="20px"></HeaderStyle
</RowIndicatorColumn
<ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column"
<HeaderStyle Width="20px"></HeaderStyle
</ExpandCollapseColumn
<Columns
<telerik:GridBoundColumn DataField="QuestionID" FilterControlAltText="Filter QuestionID column" 
HeaderText="QuestionID" UniqueName="QuestionID"
</telerik:GridBoundColumn
<telerik:GridBoundColumn DataField="Question" FilterControlAltText="Filter Question column" 
HeaderText="Question" UniqueName="Question"
</telerik:GridBoundColumn
<telerik:GridTemplateColumn FilterControlAltText="Filter column column" UniqueName="Answer" 
HeaderText="Answer"
<ItemTemplate
<asp:RadioButtonList ID="rblAnswer" runat="server" DataSourceID="sqlResponses" DataTextField="Answer" 
DataValueField="AnswerID" RepeatLayout="Table"
</asp:RadioButtonList
</ItemTemplate
</telerik:GridTemplateColumn
</Columns
<EditFormSettings
<EditColumn FilterControlAltText="Filter EditCommandColumn column"
</EditColumn
</EditFormSettings
</MasterTableView
<FilterMenu EnableImageSprites="False"
<WebServiceSettings
<ODataSettings InitialContainerName=""
</ODataSettings
</WebServiceSettings
</FilterMenu
<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"
<WebServiceSettings
<ODataSettings InitialContainerName=""
</ODataSettings
</WebServiceSettings
</HeaderContextMenu
</telerik:RadGrid
<asp:SqlDataSource ID="sqlManufacturerSurvey" runat="server" ConnectionString="<%$ ConnectionStrings:KPortal %>" 
SelectCommand="SELECT MaterialCategory.ServiceTypeID, Question.MaterialID AS QuestionID, Question.MaterialName AS Question FROM MaterialCategory INNER JOIN Materials AS Question ON MaterialCategory.MaterialCategoryID = Question.MaterialCategoryID WHERE (MaterialCategory.MaterialCategory = 'Manufacturer Survey') AND (Question.InternalCode = 'QUESTION')"> 
</asp:SqlDataSource
<asp:SqlDataSource ID="sqlResponses" runat="server" ConnectionString="<%$ ConnectionStrings:KPortal %>" 
SelectCommand="SELECT MaterialID AnswerID, MaterialName as Answer, ParentMaterialID as QuestionID FROM Materials WHERE (ParentMaterialID = @QuestionID)"> 
<SelectParameters
<asp:ControlParameter ControlID="RadGrid1" Name="QuestionID" 
PropertyName="SelectedValue" /> 
</SelectParameters
</asp:SqlDataSource
Sushil
Top achievements
Rank 1
 answered on 06 Apr 2015
1 answer
81 views
On the following tutorial, the edit from is loaded on initial page load:

http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/form-template-update/defaultcs.aspx

How can I hide it on initial load and have it appear once user click on the "edit" text on the row of the data?

In addition, how can I use RadioButtonList in the template form with particular data selected when they click on edit link?

Lastly, If in the edit template, if there is a section where I don't want it to show (because section is not necessary to be edited), can I hide the section of edit form template on the fly?
Eyup
Telerik team
 answered on 06 Apr 2015
1 answer
123 views
Hi,
i am using asp.net cascadiung dropdown
lists.
assignment
2.task




i have bind data to both dropdownlist and succesfully write insert code.
But my problem is when i next time go that page grid must show previously inserted data.
For this i can able to bind assignment dropdown but my task dropdown is not binding properly.
It shows all data for that current assignment(not showing which task is allready inserted for that
assignment.)

i tried following code for assignment
and task binding.

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType ==DataControlRowType.DataRow)
{
DropDownList ddlAssignment = (e.Row.FindControl("ddlAssignment") as DropDownList);
string Assignment =(e.Row.FindControl("lblAssignment") as Label).Text;
ddlAssignment.ClearSelection();
ddlAssignment.Items.FindByText(Assignment).Selected = true;

DropDownList ddlTask = (e.Row.FindControl("ddlTask") as DropDownList);
string Task = (e.Row.FindControl("lblTask") as Label).Text;
ddlTask.ClearSelection();
ddlTask.Items.FindByText(Task).Selected = true;

i also tried
ddlTask.Items.FindByValue(Task).Selected = true;

}
}

Thanks.

Ivan Danchev
Telerik team
 answered on 06 Apr 2015
10 answers
198 views

While using a Grid with Grouped columns, we have found that when we scroll to the right, little space is left for the left most column and in that case, only the first column in the leftmost groups is shown.

 

Please see the attached image.

Notice that the width of the grouped column crops the column as indicated in the image. Please assist.

 

Is there a way to show avoid cropping of the right sub-column in the group.

Pavlina
Telerik team
 answered on 06 Apr 2015
1 answer
66 views
i tried to change the style to keep all stars in one line.horizontally. not sure how can i fix it. please find the image. and i am looking for expactedresult in second image.
Slav
Telerik team
 answered on 06 Apr 2015
1 answer
108 views
Clicks are # in ContentTemplate with RadSitemap and  is not working on iPad.
Please check http://sieger.ontwikkelruimte.nl/test.aspx

With code:

<telerik:RadMenu id="RadMenu2" EnableShadows="false" ExpandAnimation-Type="None" CollapseAnimation-Type="None" ShowToggleHandle="false" CausesValidation="False" runat="server" >

         <Items>

           



               <telerik:RadMenuItem Value="Producten" Text="Producten" PostBack="false">
                        <ContentTemplate>
                            <div>
                              
                                <telerik:RadSiteMap ID="RadSiteMap2" runat="server" Skin="Telerik" EnableTextHTMLEncoding="true">
                                    <LevelSettings>
                                        <telerik:SiteMapLevelSetting Level="0">
                                            <ListLayout RepeatColumns="3" RepeatDirection="Vertical" />
                                        </telerik:SiteMapLevelSetting>
                                    </LevelSettings>

                                   <Nodes>
                                       <telerik:RadSiteMapNode NavigateUrl="~/abc.aspx" Text="henk" />
                                   </Nodes>
                                    </telerik:RadSiteMap>
                                </div>
                            </ContentTemplate>
                        </telerik:RadMenuItem>

             </Items>
     </telerik:RadMenu>
Dimitar
Telerik team
 answered on 06 Apr 2015
Narrow your results
Selected tags
Tags
+? more
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?