我有一个网格(父网格),它有一些行。当我展开每一行时,我有两个标签,然后点击每个标签,我显示其他网格(子网格)。
<telerik:RadGrid ID="RadGrid1" OnPreRender="RadGrid1_PreRender" DataSourceID="SqlDataSource1" Visible="false"
runat="server" AutoGenerateColumns="False" AllowSorting="True" AllowMultiRowSelection="False"
AllowPaging="True" PageSize="5" GridLines="None" ShowGroupPanel="true" OnItemCreated="RadGrid1_ItemCreated"
OnItemCommand="RadGrid1_ItemCommand">
<PagerStyle Mode="NumericPages"></PagerStyle>
<MasterTableView DataSourceID="SqlDataSource1" HierarchyDefaultExpanded="true" DataKeyNames="EmployeeID" AllowMultiColumnSorting="True"
GroupLoadMode="Server" EditMode ="Batch">
<NestedViewTemplate>
<asp:Panel runat="server" ID="InnerContainer" CssClass="viewWrap" Visible="false">
<telerik:RadTabStrip runat="server" ID="TabStip1" MultiPageID="Multipage1" SelectedIndex="0">
<Tabs>
<telerik:RadTab runat="server" Text="First Grid" PageViewID="PageView1">
</telerik:RadTab>
<telerik:RadTab runat="server" Text="Second Grid" PageViewID="PageView2">
</telerik:RadTab>
</Tabs>
</telerik:RadTabStrip>
<telerik:RadMultiPage runat="server" ID="Multipage1" SelectedIndex="0" RenderSelectedPageOnly="false">
<telerik:RadPageView runat="server" ID="PageView1">
<asp:Label ID="Label1" Font-Bold="true" Font-Italic="true" Text='<%# Eval("EmployeeID") %>'
Visible="false" runat="server"></asp:Label>
<telerik:RadGrid runat="server" ID="OrdersGrid" DataSourceID="SqlDataSource2" ShowFooter="true"
AllowSorting="true" EnableLinqExpressions="false">
<MasterTableView ShowHeader="true" AutoGenerateColumns="False" AllowPaging="true"
DataKeyNames="OrderID" PageSize="7" HierarchyLoadMode="ServerOnDemand">
<DetailTables>
<telerik:GridTableView AutoGenerateColumns="false" DataKeyNames="OrderID" DataSourceID="SqlDataSource3"
Width="100%">
<ParentTableRelation>
<telerik:GridRelationFields DetailKeyField="OrderID" MasterKeyField="OrderID"></telerik:GridRelationFields>
</ParentTableRelation>
<Columns>
<telerik:GridHyperLinkColumn SortExpression="ProductName" DataTextFormatString="Search Google for '{0}'"
DataNavigateUrlFields="ProductName" UniqueName="ProductName" DataNavigateUrlFormatString="http://www.google.com/search?hl=en&q={0}&btnG=Google+Search"
HeaderText="HyperLink Column" DataTextField="ProductName">
</telerik:GridHyperLinkColumn>
<telerik:GridNumericColumn SortExpression="UnitPrice" HeaderText="Unit Price" HeaderButtonType="TextButton"
DataField="UnitPrice" DataFormatString="{0:C}" Aggregate="Avg" FooterAggregateFormatString="Average price: {0:C}">
</telerik:GridNumericColumn>
<telerik:GridNumericColumn SortExpression="Quantity" HeaderText="Quantity" HeaderButtonType="TextButton"
DataField="Quantity" Aggregate="Max" FooterAggregateFormatString="Max quantity: {0}">
</telerik:GridNumericColumn>
<telerik:GridNumericColumn SortExpression="Discount" HeaderText="Discount" HeaderButtonType="TextButton"
DataField="Discount" DataFormatString="{0:P}">
</telerik:GridNumericColumn>
<telerik:GridCalculatedColumn UniqueName="Total" DataFields="UnitPrice,Quantity,Discount"
Expression="IIf({2} = 0,{0}*{1}, {0}*{1}*{2})" HeaderText="Total" DataType="System.Double"
Aggregate="Sum" DataFormatString="{0:C}" FooterAggregateFormatString="Total cost: {0:C}">
</telerik:GridCalculatedColumn>
</Columns>
<SortExpressions>
<telerik:GridSortExpression FieldName="Quantity" SortOrder="Descending"></telerik:GridSortExpression>
</SortExpressions>
</telerik:GridTableView>
</DetailTables>
<Columns>
<telerik:GridBoundColumn SortExpression="CompanyName" HeaderText="CompanyName" HeaderButtonType="TextButton"
DataField="CompanyName" UniqueName="CompanyName">
</telerik:GridBoundColumn>
<telerik:GridHyperLinkColumn SortExpression="CompanyName" DataTextFormatString="Search Google for '{0}'"
DataNavigateUrlFields="CompanyName" UniqueName="CompanyName" DataNavigateUrlFormatString="http://www.google.com/search?hl=en&q={0}&btnG=Google+Search"
HeaderText="HyperLink Column" DataTextField="CompanyName">
</telerik:GridHyperLinkColumn>
<telerik:GridBoundColumn SortExpression="OrderID" HeaderText="OrderID" HeaderButtonType="TextButton"
DataField="OrderID" UniqueName="OrderID" Aggregate="Count" FooterAggregateFormatString="Orders count: {0}">
</telerik:GridBoundColumn>
<telerik:GridDateTimeColumn SortExpression="OrderDate" HeaderText="Order date" HeaderButtonType="TextButton"
DataField="OrderDate" UniqueName="OrderDate" DataFormatString="{0:MM/dd/yyyy}"
Aggregate="Last" FooterAggregateFormatString="Last order dates: {0:d}">
</telerik:GridDateTimeColumn>
<telerik:GridBoundColumn UniqueName="Total" DataField="Total" HeaderText="Order Total"
SortExpression="Total" DataFormatString="{0:C}">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
<ClientSettings AllowDragToGroup="true">
<Scrolling AllowScroll="true" ScrollHeight="" />
</ClientSettings>
<PagerStyle PageButtonCount="3" Mode="NextPrevAndNumeric" ShowPagerText="false" />
</telerik:RadGrid>
<asp:SqlDataSource ID="SqlDataSource2" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
ProviderName="System.Data.SqlClient" SelectCommand="SELECT Orders.OrderID, Orders.OrderDate, Orders.Freight, Customers.CompanyName, SUM(
CASE WHEN [Order Details].Discount = 0 THEN 1
ELSE [Order Details].Discount END
* [Order Details].Quantity * [Order Details].UnitPrice) as Total
FROM (Orders LEFT JOIN Customers on Orders.CustomerID = Customers.CustomerID)
FULL JOIN [Order Details] on Orders.OrderID = [Order Details].OrderID
Where EmployeeID = @EmployeeID
GROUP BY Orders.OrderID,Orders.OrderDate, Orders.Freight, Customers.CompanyName"
runat="server">
<SelectParameters>
<asp:ControlParameter ControlID="Label1" PropertyName="Text" Type="String" Name="EmployeeID"></asp:ControlParameter>
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource3" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
ProviderName="System.Data.SqlClient" SelectCommand="SELECT OrderID, [Order Details].UnitPrice, Quantity, Discount, Products.ProductName FROM ([Order Details] LEFT JOIN Products on [Order Details].ProductID = Products.ProductID) where OrderID = @OrderID"
runat="server">
<SelectParameters>
<asp:SessionParameter Name="OrderID" SessionField="OrderID" Type="Int32"></asp:SessionParameter>
</SelectParameters>
</asp:SqlDataSource>
</telerik:RadPageView>
<telerik:RadPageView runat="server" ID="PageView">
<telerik:RadGrid runat="server" ID="RadGrid4" DataSourceID="SqlDataSource2" AutoGenerateColumns="true"
AllowSorting="true">
</telerik:RadGrid>
</telerik:RadPageView>
</telerik:RadMultiPage>
</asp:Panel>
</NestedViewTemplate>
<Columns>
<telerik:GridBoundColumn SortExpression="FirstName" HeaderText="First Name" HeaderButtonType="TextButton"
DataField="FirstName" UniqueName="FirstName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn SortExpression="LastName" HeaderText="Last Name" HeaderButtonType="TextButton"
DataField="LastName" UniqueName="LastName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn SortExpression="Title" HeaderText="Title" HeaderButtonType="TextButton"
DataField="Title" UniqueName="Title">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn SortExpression="BirthDate" DataFormatString="{0:MM/dd/yyyy}"
HeaderText="Birth Date" HeaderButtonType="TextButton" DataField="BirthDate" UniqueName="BirthDate">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn SortExpression="City" HeaderText="City" HeaderButtonType="TextButton"
DataField="City" UniqueName="City">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn SortExpression="Country" HeaderText="Country" HeaderButtonType="TextButton"
DataField="Country" UniqueName="Country">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
<ClientSettings AllowDragToGroup="true">
<Scrolling AllowScroll="true" ScrollHeight="" />
</ClientSettings>
</telerik:RadGrid>
我正在实现网格的自动刷新。为此,我使用了定时器控制并设置了10分钟的间隔。
<asp:Timer runat="server" ID="Timer1" Interval="600000" OnTick="Timer1_Tick"></asp:Timer>
protected void Timer1_Tick(object sender, EventArgs e) {
ragdgrid1.rebind();
radgrid2.rebind();
}
我的问题是当网格处于编辑模式时(我正在使用批量编辑)并且达到计时器间隔时它会刷新网格并且我们将失去编辑模式。因此用户再次需要输入网格的值。
当达到计时器间隔时,如何将网格保持在编辑模式?