后台代码做了数据绑定,前台同时设置了datafiled。
你可以在前台做绑定,把后台数据去掉。
也可以把目前后台代码保留,前台代码删了。然后再后台绑定之后,设置各个column的属性。
下面是一个前台绑定的例子
- <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
- <asp:ScriptManager runat="server" ID="ScriptManager1" />
-
- <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
- <ContentTemplate>
- <wijmo:C1GridView ID="C1GridView1" runat="server" DataSourceID="SqlDataSource1"
- AutoGenerateColumns="false" ShowRowHeader="true" AllowColMoving="true" AllowSorting="true">
- <ScrollingSettings Mode="Auto">
- </ScrollingSettings>
- <Columns>
- <wijmo:C1BoundField DataField="OrderID" HeaderText="ID" SortExpression="OrderID" DataFormatString="d"/>
- <wijmo:C1BoundField DataField="ShipName" HeaderText="Ship name" SortExpression="ShipName" />
- <wijmo:C1BoundField DataField="ShipCity" HeaderText="Ship city" SortExpression="ShipCity"/>
- <wijmo:C1Band HeaderText="Dates">
- <Columns>
- <wijmo:C1BoundField DataField="OrderDate" HeaderText="Order date" DataFormatString="d" SortExpression="OrderDate" />
- <wijmo:C1BoundField DataField="RequiredDate" HeaderText="Required date" DataFormatString="d" SortExpression="RequiredDate" />
- <wijmo:C1BoundField DataField="ShippedDate" HeaderText="Shipped date" DataFormatString="d" SortExpression="ShippedDate" />
- </Columns>
- </wijmo:C1Band>
- </Columns>
- </wijmo:C1GridView>
- </ContentTemplate>
- </asp:UpdatePanel>
- <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\C1NWind.mdb;Persist Security Info=True"
- ProviderName="System.Data.OleDb" SelectCommand="SELECT TOP 10 [OrderID], [ShipName], [ShipCity], [OrderDate], [RequiredDate], [ShippedDate] FROM ORDERS">
- </asp:SqlDataSource>
- </asp:Content>
复制代码 |