0

我有这个似乎正在获取数据但没有显示的 radgrid。绑定后 grid.Items.Count 设置为预期的行数。我将包括 ajax 管理器设置和网格。有兴趣的请备注。在 onRequestStart javascript 中,我只是在做一些客户端验证。谢谢!

这是适当的片段:

 <telerik:radajaxmanager id="RadAjaxManager1" runat="server"> 
         <clientevents onrequeststart="onRequestStart" />
        <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadAjaxPanel1">
                </telerik:AjaxUpdatedControl>
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="RadBtnRetrieve">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadPanelBar1" loadingpanelid="RadAjaxLoadingPanel1">
                </telerik:AjaxUpdatedControl>
                <telerik:ajaxupdatedcontrol controlid="RadAjaxPanel1" loadingpanelid="RadAjaxLoadingPanel1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="RadGridPartsWashers">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadGridPartsWashers" loadingpanelid="RadAjaxLoadingPanel1">
                </telerik:AjaxUpdatedControl>
            </UpdatedControls>
        </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:radajaxmanager>



 <telerik:radajaxpanel ID="RadAjaxPanel1" runat="server" loadingpanelid="RadAjaxLoadingPanel1" enableajax="true">
        <table>
            <tr>
                <td>
                    <telerik:RadGrid ID="RadGridPartsWashers" runat="server" Width="100%" AllowPaging="True"
                        CellSpacing="0" GridLines="None" AllowSorting="True" AutoGenerateColumns="False"
                        CssClass="RadGrid.rgMasterTable" onneeddatasource="RadGridPartsWashers_NeedDataSource">
                        <ClientSettings>
                            <Selecting AllowRowSelect="True"></Selecting>
                            <Scrolling AllowScroll="True" ScrollHeight="" UseStaticHeaders="True"></Scrolling>
                            <Resizing AllowColumnResize="true" />
                        </ClientSettings>
                        <MasterTableView EnableHeaderContextMenu="true" EnableNoRecordsTemplate="true" DataKeyNames="AssetNumber"
                            EnableSplitHeaderText="true" TableLayout="Auto" Width="100%">
                            <PagerStyle AlwaysVisible="true" />
                            <NoRecordsTemplate>
                                <div>
                                    There are no records to display
                                </div>
                            </NoRecordsTemplate>
                            <Columns>
                              .....
                             </Columns>
4

1 回答 1

0

这是 Telerik 示例 public partial class DefaultCS 中的一个示例: System.Web.UI.Page { public void Page_Load(object sender, System.EventArgs e) { if (!IsPostBack) { LoadData(); }
}

        protected void RadGrid1_PageSizeChanged(object source, GridPageSizeChangedEventArgs e)
        {
            LoadData();
        }

        private void LoadData()
        {
            RadGrid1.DataSource = GetDataTable("SELECT CustomerID, CompanyName, ContactName, ContactTitle, Address, PostalCode FROM Customers");
        }

        protected void RadGrid1_PageIndexChanged(object source, Telerik.Web.UI.GridPageChangedEventArgs e)
        {
            LoadData();
        }

        protected void RadGrid1_SortCommand(object source, Telerik.Web.UI.GridSortCommandEventArgs e)
        {
            LoadData();
        }

        public DataTable GetDataTable(string query)
        {
            String ConnString = ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString;
            SqlConnection conn = new SqlConnection(ConnString);
            SqlDataAdapter adapter = new SqlDataAdapter();
            adapter.SelectCommand = new SqlCommand(query, conn);

            DataTable myDataTable = new DataTable();

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

            return myDataTable;
        }
    }

你忘了放 RadGrid1.DataBind 吗?

问候,雨果佩德罗萨

于 2013-05-20T22:07:48.443 回答