添加按钮和文本框,然后在radgrid中使用文本框的内容

时间:2019-01-27 16:21:59

标签: telerik-grid

我创建了一个具有radgrid的Web表单,并显示存储过程中的数据。现在,我想在页面顶部添加一个按钮和一个文本框。单击按钮后,我想获得用户在文本框中输入的内容,并将其用作存储过程的参数,然后在radgrid中显示结果。我该如何获取?

下面是ASP代码以及我现在拥有的代码:

ASP代码:

<%@ Page Title="Shipping Schedule" Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true" CodeBehind="ShipSchedule.aspx.cs" Inherits="FinancialReporting.Reports.ShippingSchedule.ShipSchedule" %>

    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <%--<link href="../../styles/default.css" rel="stylesheet" />--%>
    <style type="text/css">
        .labelPadded {
            padding-right: 10px;
        }

        .doc-link {
            font-size: small;
        }

        div.t-col-10 {
            width: 100%;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
    <h3>Shipping Schedule</h3>
    <span class="doc-link"><a target="_blank" href="../../Resources/Documentation/Override%20Sales%20Data.pdf">How to use this page</a></span>
    <div>
        <p><b>Note: This is to accommodate dates that do not have a place to be stored in E1.</b></p> -->
    </div>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
    </telerik:RadAjaxLoadingPanel>

    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1" EnableAJAX="true">
        <telerik:RadGrid
            ID="grdShippingData"
            runat="server"
            RenderMode="Lightweight"
            AutoGenerateColumns="false"
            Width="99%"
            OnNeedDataSource="grdShippingData_NeedDataSource"
            OnItemDataBound="grdShippingData_ItemDataBound"
            OnUpdateCommand="grdShippingData_UpdateCommand"
            AllowFilteringByColumn="true"
            AllowPaging="true"
            PageSize="20"
            AllowSorting="true"
            OnPreRender="grdShippingData_PreRender" ExportSettings-ExportOnlyData="False">
            <GroupingSettings CaseSensitive="false"></GroupingSettings>

            <MasterTableView
                TableLayout="Auto"
                CommandItemDisplay="Top"
                InsertItemPageIndexAction="ShowItemOnFirstPage"
                EditMode="InPlace">
                <CommandItemSettings ShowExportToCsvButton="false" ShowExportToExcelButton="true" ShowExportToPdfButton="false" ShowExportToWordButton="false" ShowAddNewRecordButton="false" />
                <Columns>
                    <telerik:GridBoundColumn UniqueName="vcBusinessTypeName" SortExpression="vcBusinessTypeName" HeaderText="Business Type" DataField="vcBusinessTypeName" ReadOnly="true" AllowFiltering="true">
                        <FilterTemplate>
                            <telerik:RadComboBox RenderMode="Lightweight" ID="rcbBusinessTypeName" DataSourceID="sqlGetBusinessTypes" DataTextField="vcBusinessTypeName"
                                DataValueField="vcBusinessTypeName" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("vcBusinessTypeName").CurrentFilterValue %>'
                                runat="server" OnClientSelectedIndexChanged="ChangeBusiness" DropDownAutoWidth="Enabled" MaxHeight="200px">
                                <Items>
                                    <telerik:RadComboBoxItem Text="All" />
                                </Items>
                            </telerik:RadComboBox>
                            <telerik:RadScriptBlock ID="rsbBusinessTypeName" runat="server">
                                <script type="text/javascript">
                                    function ChangeBusiness(sender, args) {
                                        var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                        tableView.filter("vcBusinessTypeName", args.get_item().get_value(), "EqualTo");
                                    }
                                </script>
                            </telerik:RadScriptBlock>
                        </FilterTemplate>
                    </telerik:GridBoundColumn>

                    <telerik:GridBoundColumn UniqueName="vcCategory" SortExpression="vcCategory" HeaderText="Category" DataField="vcCategory" ReadOnly="true" AllowFiltering="false" />
                    <telerik:GridBoundColumn UniqueName="vcCompany" SortExpression="vcCompany" HeaderText="Company" DataField="vcCompany" ReadOnly="true" AllowFiltering="false" />
                    <telerik:GridBoundColumn UniqueName="vcOrderNumber" SortExpression="vcOrderNumber" HeaderText="Order Number" DataField="vcOrderNumber" ReadOnly="true" AllowFiltering="false" />
                    <telerik:GridDateTimeColumn DataField="dtShipDate" HeaderText="Ship Date" UniqueName="dtShipDate" PickerType="DatePicker" SortExpression="dtShipDate" ReadOnly="true" DataFormatString="{0:d}" AllowFiltering="false" ItemStyle-HorizontalAlign="Right" />
                    <telerik:GridBoundColumn UniqueName="vcCustomer" SortExpression="vcCustomer" HeaderText="Customer" DataField="vcCustomer" ReadOnly="true" AllowFiltering="false" />
                    <telerik:GridBoundColumn UniqueName="vcIndustry" SortExpression="vcIndustry" HeaderText="Industry" DataField="vcIndustry" ReadOnly="true" AllowFiltering="false" />
                    <telerik:GridBoundColumn UniqueName="vcMachineDescription" SortExpression="vcMachineDescription" HeaderText="Machine Description" DataField="vcMachineDescription" ReadOnly="true" AllowFiltering="false" />
                    <telerik:GridNumericColumn DataField="dQuantity" HeaderText="Quantity" UniqueName="dQuantity" DataFormatString="{0:C}" AllowFiltering="false" ReadOnly="true" ItemStyle-HorizontalAlign="Right" />
                    <telerik:GridNumericColumn DataField="dTotal" HeaderText="Total Price" UniqueName="dTotal" DataFormatString="{0:C}" AllowFiltering="false" ReadOnly="true" ItemStyle-HorizontalAlign="Right" />
                    <telerik:GridBoundColumn UniqueName="bType" SortExpression="bType" HeaderText="Type" DataField="bType" ReadOnly="true" AllowFiltering="false" />
                    <telerik:GridBoundColumn UniqueName="dtQuarter" SortExpression="dtQuarter" HeaderText="Quarter" DataField="dtQuarter" ReadOnly="true" AllowFiltering="false" />
                    <telerik:GridBoundColumn UniqueName="Status" SortExpression="Status" HeaderText="Status" DataField="Status" ReadOnly="true" AllowFiltering="false" />
                    <telerik:GridBoundColumn UniqueName="Invoiced" SortExpression="Invoiced" HeaderText="Invoiced" DataField="Invoiced" ReadOnly="true" AllowFiltering="false" />
                    <telerik:GridBoundColumn UniqueName="vcShippingTermCode" SortExpression="vcShippingTermCode" HeaderText="Shipping Term Code" DataField="vcShippingTermCode" ReadOnly="true" AllowFiltering="false" />
                    <telerik:GridBoundColumn UniqueName="vcShippingTermDescription" SortExpression="vcShippingTermDescription" HeaderText="Shipping Term Description" DataField="vcShippingTermDescription" ReadOnly="true" AllowFiltering="false" />
                    <telerik:GridBoundColumn UniqueName="CustomPaymentTerms" SortExpression="CustomPaymentTerms" HeaderText="Custom Payment Terms" DataField="CustomPaymentTerms" ReadOnly="true" AllowFiltering="false" />
                    <telerik:GridBoundColumn UniqueName="FreightDescription" SortExpression="FreightDescription" HeaderText="Freight Description" DataField="FreightDescription" ReadOnly="true" AllowFiltering="false" />
                    <telerik:GridBoundColumn UniqueName="FreightHandling" SortExpression="FreightHandling" HeaderText="Freight Handling" DataField="FreightHandling" ReadOnly="true" AllowFiltering="false" />

                    <%-- Columns where you can add data:  AcceptanceCriteria and Risk --%>
                    <telerik:GridBoundColumn DataField="vcAcceptanceCriteria" HeaderText="Acceptance Criteria" UniqueName="vcAcceptanceCriteria" SortExpression="vcAcceptanceCriteria" MaxLength="255" AllowFiltering="false" />
                    <telerik:GridBoundColumn DataField="vcRisk" HeaderText="Risk" UniqueName="vcRisk" SortExpression="vcRisk" MaxLength="255" AllowFiltering="false" />

                    <telerik:GridDateTimeColumn DataField="dtOrderDate" HeaderText="Order Date" UniqueName="dtOrderDate" PickerType="DatePicker" SortExpression="dtOrderDate" ReadOnly="true" DataFormatString="{0:d}" AllowFiltering="false" ItemStyle-HorizontalAlign="Right" />
                    <telerik:GridDateTimeColumn DataField="dtOriginalShipDate" HeaderText="Original Ship Date" UniqueName="dtOriginalShipDate" PickerType="DatePicker" SortExpression="dtOriginalShipDate" ReadOnly="true" DataFormatString="{0:d}" AllowFiltering="false" ItemStyle-HorizontalAlign="Right" />
                    <telerik:GridDateTimeColumn DataField="dtCurrentShipDate" HeaderText="Current Ship Date" UniqueName="dtCurrentShipDate" PickerType="DatePicker" SortExpression="dtCurrentShipDate" ReadOnly="true" DataFormatString="{0:d}" AllowFiltering="false" ItemStyle-HorizontalAlign="Right" />
                    <telerik:GridDateTimeColumn DataField="dtActualFinal" HeaderText="Actual Final" UniqueName="dtActualFinal" PickerType="DatePicker" SortExpression="dtActualFinal" ReadOnly="true" DataFormatString="{0:d}" AllowFiltering="false" ItemStyle-HorizontalAlign="Right" />

                    <%--Columns you can filter from:  Recognition, Region and Specification--%>
                    <telerik:GridBoundColumn UniqueName="vcRecognition" SortExpression="vcRecognition" HeaderText="Recognition" DataField="vcRecognition" ReadOnly="true" AllowFiltering="true">
                        <FilterTemplate>
                            <telerik:RadComboBox RenderMode="Lightweight" ID="rcbRecognition" DataSourceID="sqlGetRecognition" DataTextField="vcRecognition"
                                DataValueField="vcRecognition" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("vcRecognition").CurrentFilterValue %>'
                                runat="server" OnClientSelectedIndexChanged="ChangeRec" DropDownAutoWidth="Enabled" MaxHeight="200px">
                                <Items>
                                    <telerik:RadComboBoxItem Text="All" />
                                </Items>
                            </telerik:RadComboBox>
                            <telerik:RadScriptBlock ID="rsbRecognition" runat="server">
                                <script type="text/javascript">
                                    function ChangeRec(sender, args) {
                                        var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                        tableView.filter("vcRecognition", args.get_item().get_value(), "EqualTo");
                                    }
                                </script>
                            </telerik:RadScriptBlock>
                        </FilterTemplate>
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn UniqueName="vcRegion" SortExpression="vcRegion" HeaderText="Region" DataField="vcRegion" ReadOnly="true" AllowFiltering="true">
                        <FilterTemplate>
                            <telerik:RadComboBox RenderMode="Lightweight" ID="rcbRegion" DataSourceID="sqlGetRegion" DataTextField="vcRegion"
                                DataValueField="vcRegion" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("vcRegion").CurrentFilterValue %>'
                                runat="server" OnClientSelectedIndexChanged="ChangeRegion" DropDownAutoWidth="Enabled" MaxHeight="200px">
                                <Items>
                                    <telerik:RadComboBoxItem Text="All" />
                                </Items>
                            </telerik:RadComboBox>
                            <telerik:RadScriptBlock ID="rsbRegion" runat="server">
                                <script type="text/javascript">
                                    function ChangeRegion(sender, args) {
                                        var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                        tableView.filter("vcRegion", args.get_item().get_value(), "EqualTo");
                                    }
                                </script>
                            </telerik:RadScriptBlock>
                        </FilterTemplate>
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn UniqueName="vcSpecificationDescription" SortExpression="vcSpecificationDescription" HeaderText="Specification" DataField="vcSpecificationDescription" ReadOnly="true" AllowFiltering="true">
                        <FilterTemplate>
                            <telerik:RadComboBox RenderMode="Lightweight" ID="rcbSpecification" DataSourceID="sqlGetSpecification" DataTextField="vcSpecificationDescription"
                                DataValueField="vcSpecificationDescription" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("vcSpecificationDescription").CurrentFilterValue %>'
                                runat="server" OnClientSelectedIndexChanged="GroupChangeSpecification" DropDownAutoWidth="Enabled" MaxHeight="200px">
                                <Items>
                                    <telerik:RadComboBoxItem Text="All" />
                                </Items>
                            </telerik:RadComboBox>
                            <telerik:RadScriptBlock ID="rsbSpecification" runat="server">
                                <script type="text/javascript">
                                    function GroupChangeSpecification(sender, args) {
                                        var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                        tableView.filter("vcSpecificationDescription", args.get_item().get_value(), "EqualTo");
                                    }
                                </script>
                            </telerik:RadScriptBlock>
                        </FilterTemplate>
                    </telerik:GridBoundColumn>

                    <telerik:GridBoundColumn UniqueName="ProductionDates" SortExpression="ProductionDates" HeaderText="Production Date" DataField="ProductionDates" ReadOnly="true" AllowFiltering="false" />
                    <telerik:GridBoundColumn UniqueName="Shipping" SortExpression="Shipping" HeaderText="Shipping" DataField="Shipping" ReadOnly="true" AllowFiltering="false" />
                    <telerik:GridBoundColumn UniqueName="Acceptance" SortExpression="Acceptance" HeaderText="Acceptance" DataField="Acceptance" ReadOnly="true" AllowFiltering="false" />
                    <telerik:GridBoundColumn UniqueName="Credit" SortExpression="Credit" HeaderText="Credit" DataField="Credit" ReadOnly="true" AllowFiltering="false" />

                    <%-- Column for edit button --%>
                    <telerik:GridEditCommandColumn HeaderText="Edit" UniqueName="EditColumn" ButtonType="ImageButton" />

                    <%-- Order *read only* data columns --%>
                    <%--<telerik:GridNumericColumn UniqueName="dLineNbr" SortExpression="dLineNbr" HeaderText="Line Number" DataField="dLineNbr" ReadOnly="true" Visible="false" AllowFiltering="false" />--%>
                    <%--<telerik:GridNumericColumn DataField="dTotal" HeaderText="Total Price" UniqueName="dTotal" DataFormatString="{0:C}" AllowFiltering="false" ReadOnly="true" ItemStyle-HorizontalAlign="Right" />--%>
                    <%--<telerik:GridDateTimeColumn DataField="dtOrderDate" HeaderText="Order Date" UniqueName="dtOrderDate" PickerType="DatePicker" SortExpression="dtOrderDate" ReadOnly="true" DataFormatString="{0:d}" AllowFiltering="false" ItemStyle-HorizontalAlign="Right" />--%>
                    <%--<telerik:GridDateTimeColumn DataField="dtShipDate" HeaderText="Ship Date" UniqueName="dtShipDate" PickerType="DatePicker" SortExpression="dtShipDate" ReadOnly="true" DataFormatString="{0:d}" AllowFiltering="false" ItemStyle-HorizontalAlign="Right" />--%>

                    <%-- Order *editable* data columns --%>
                    <%-- <telerik:GridDateTimeColumn DataField="dtFinalProjectedShipDate" HeaderText="Projected Date" UniqueName="dtFinalProjectedShipDate" PickerType="DatePicker" SortExpression="dtFinalProjectedShipDate" DataFormatString="{0:d}" AllowFiltering="true" EnableRangeFiltering="true" AutoPostBackOnFilter="true" ItemStyle-HorizontalAlign="Center" /> --%>
                    <%--<telerik:GridDateTimeColumn DataField="dtOverrideDate" HeaderText="Override Date" UniqueName="dtOverrideDate" PickerType="DatePicker" SortExpression="dtOverrideDate" DataFormatString="{0:d}" AllowFiltering="false" Display="false" /> --%>    
                </Columns>

                <%--<Columns>
                    <telerik:GridEditCommandColumn UniqueName="EditColumn" ButtonType="LinkButton" />
                </Columns>--%>
            </MasterTableView>
        </telerik:RadGrid>
    </telerik:RadAjaxPanel>
    <asp:SqlDataSource ID="sqlGetBusinessTypes" ConnectionString="<%$ ConnectionStrings:FinancialReporting %>"
        ProviderName="System.Data.SqlClient"
        SelectCommand="SELECT DISTINCT
                       vcBusinessTypeName
                       FROM V_SoldPositionCategories_Summary as V
                       INNER JOIN  AdminUserAllowedGroups as UAG
                            ON V.uidSoldPositionGroups=UAG.uidSoldPositionGroups
                            AND UAG.vcUserId=@vcUserId
                            AND UAG.bActive=1
                        WHERE
                                (vcRecognition=@vcRecognition OR 'All'=@vcRecognition) 
                            AND (vcRegion=@vcRegion OR 'All'=@vcRegion)
                            AND (vcSpecificationDescription=@vcSpecificationDescription OR 'All'=@vcSpecificationDescription)"
        runat="server">
        <SelectParameters>
            <%-- Creating parameters for above select statement. The value will come from the aspx.cs page where sqlGetBusinessTypes is called --%>
            <asp:Parameter Name="vcUserId" Type="String" DefaultValue="Anonymous" />
            <asp:Parameter Name="vcRecognition" Type="String" DefaultValue="All" />
            <asp:Parameter Name="vcRegion" Type="String" DefaultValue="All" />
            <asp:Parameter Name="vcSpecificationDescription" Type="String" DefaultValue="All" />
        </SelectParameters>
    </asp:SqlDataSource>

    <asp:SqlDataSource ID="sqlGetRecognition" ConnectionString="<%$ ConnectionStrings:FinancialReporting %>"
        ProviderName="System.Data.SqlClient"
        SelectCommand="SELECT DISTINCT
                       vcRecognition
                       FROM V_SoldPositionCategories_Summary as V
                       INNER JOIN AdminUserAllowedGroups as UAG
                            ON V.uidSoldPositionGroups=UAG.uidSoldPositionGroups
                            AND UAG.vcUserId=@vcUserId
                            AND UAG.bActive=1
                       WHERE
                                (vcBusinessTypeName=@vcBusinessTypeName OR 'All'=@vcBusinessTypeName) 
                            AND (vcRegion=@vcRegion OR 'All'=@vcRegion)
                            AND (vcSpecificationDescription=@vcSpecificationDescription OR 'All'=@vcSpecificationDescription)"
        runat="server">
        <SelectParameters>
            <%-- Creating parameters for above select statement. The value will come from the aspx.cs page where sqlGetRecognition is called --%>
            <asp:Parameter Name="vcUserId" Type="String" DefaultValue="All" />
            <asp:Parameter Name="vcBusinessTypeName" Type="String" DefaultValue="All" />
            <asp:Parameter Name="vcRegion" Type="String" DefaultValue="All" />
            <asp:Parameter Name="vcSpecificationDescription" Type="String" DefaultValue="All" />
        </SelectParameters>
    </asp:SqlDataSource>

    <asp:SqlDataSource ID="sqlGetRegion" ConnectionString="<%$ ConnectionStrings:FinancialReporting %>"
        ProviderName="System.Data.SqlClient"
        SelectCommand="SELECT DISTINCT
                       vcRegion
                       FROM V_SoldPositionCategories_Summary as V
                       INNER JOIN  AdminUserAllowedGroups as UAG
                            ON V.uidSoldPositionGroups=UAG.uidSoldPositionGroups
                            AND UAG.vcUserId=@vcUserId
                            AND UAG.bActive=1
                       WHERE
                                (vcBusinessTypeName=@vcBusinessTypeName OR 'All'=@vcBusinessTypeName) 
                            AND (vcRecognition=@vcRecognition OR 'All'=@vcRecognition)
                            "
        runat="server">
        <SelectParameters>
            <%-- Creating parameters for above select statement. The value will come from the aspx.cs page where sqlGetRegion is called --%>
            <asp:Parameter Name="vcUserId" Type="String" DefaultValue="Anonymous" />
            <asp:Parameter Name="vcBusinessTypeName" Type="String" DefaultValue="All" />
            <asp:Parameter Name="vcRecognition" Type="String" DefaultValue="All" />
            <asp:Parameter Name="vcSpecificationDescription" Type="String" DefaultValue="All" />
        </SelectParameters>
    </asp:SqlDataSource>

    <asp:SqlDataSource ID="sqlGetSpecification" ConnectionString="<%$ ConnectionStrings:FinancialReporting %>"
        ProviderName="System.Data.SqlClient"
        SelectCommand="SELECT DISTINCT
                       vcSpecificationDescription
                       FROM V_SoldPositionCategories_Summary as V
                       INNER JOIN  AdminUserAllowedGroups as UAG
                            ON V.uidSoldPositionGroups=UAG.uidSoldPositionGroups
                            AND UAG.vcUserId=@vcUserId
                            AND UAG.bActive=1
                       WHERE
                                (vcBusinessTypeName=@vcBusinessTypeName OR 'All'=@vcBusinessTypeName)
                            AND (vcRecognition=@vcRecognition OR 'All'=@vcRecognition) 
                            AND (vcRegion=@vcRegion OR 'All'=@vcRegion)"
        runat="server">
        <SelectParameters>
            <%-- Creating parameters for above select statement. The value will come from the aspx.cs page where sqlGetSpecification is called --%>
            <asp:Parameter Name="vcUserId" Type="String" DefaultValue="Anonymous" />
            <asp:Parameter Name="vcBusinessTypeName" Type="String" DefaultValue="All" />
            <asp:Parameter Name="vcRecognition" Type="String" DefaultValue="All" />
            <asp:Parameter Name="vcRegion" Type="String" DefaultValue="All" />

        </SelectParameters>
    </asp:SqlDataSource>

</asp:Content>

隐藏代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using Telerik.Web.UI;

namespace FinancialReporting.Reports.ShippingSchedule
{
    public partial class ShipSchedule : System.Web.UI.Page
    {
         #region private variable declarations
        //Order detail variables
        //private string orderNumber;
        //string orderType;
        //string orderCompany;

        #endregion

        protected void Page_Init(object sender, EventArgs e)
        {
            //It gets the user ID of the person going on the page. This will be used as the parameter value of the different sql queries on the .aspx page
            sqlGetBusinessTypes.SelectParameters["vcUserId"].DefaultValue = User.Identity.Name;
            sqlGetRecognition.SelectParameters["vcUserId"].DefaultValue = User.Identity.Name;
            sqlGetRegion.SelectParameters["vcUserId"].DefaultValue = User.Identity.Name;
            sqlGetSpecification.SelectParameters["vcUserId"].DefaultValue = User.Identity.Name;
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void grdShippingData_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            String ConnString = System.Configuration.ConfigurationManager.ConnectionStrings["FinancialReporting"].ConnectionString;
            SqlConnection conn = new SqlConnection(ConnString);
            SqlDataAdapter adapter = new SqlDataAdapter();

            string sSQL = string.Empty;
            sSQL = "p_Report_Ship_Schedule";

            //Audit Variables
            string vcUserName = User.Identity.Name.ToUpper();

            //Set the Parameters for the Stored Procedure
            SqlCommand cmd = new SqlCommand(sSQL, conn); 
            cmd.CommandType = CommandType.StoredProcedure; 
            cmd.Parameters.Add(new SqlParameter("@vcUserId", vcUserName)); 

            //Configure adapter with command
            adapter.SelectCommand = cmd; 

            DataTable myDataTable = new DataTable();

            conn.Open();
            try
            {
                adapter.Fill(myDataTable);
            }
            finally
            {
                conn.Close();
            }

            grdShippingData.DataSource = myDataTable;
        }

        protected void grdShippingData_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)   //code that executes when the edit button is clicked
        {
            // Set up the properties of the vcAcceptanceCriteria and vcRisk textboxes (multiline, etc)
            if (e.Item is GridDataItem && e.Item.IsInEditMode)
            {
                GridDataItem editItem = (GridDataItem)e.Item;
                TextBox textBox = (TextBox)editItem["vcAcceptanceCriteria"].Controls[0];
                textBox.TextMode = TextBoxMode.MultiLine;
                textBox.Height = Unit.Pixel(75);
            }

            if (e.Item is GridDataItem && e.Item.IsInEditMode)
            {
                GridDataItem editItem = (GridDataItem)e.Item;
                TextBox textBox = (TextBox)editItem["vcRisk"].Controls[0];
                textBox.TextMode = TextBoxMode.MultiLine;
                textBox.Height = Unit.Pixel(75);
            }
        }
    }         
}

0 个答案:

没有答案