This is the old method that I would like to replace with sf components to clean it up:
<div class="form-row">
<div class="col">
<asp:GridView ID="GridViewList" runat="server" AutoGenerateColumns="False" DataKeyNames="TourID" DataSourceID="dsTours" AllowPaging="True">
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="TourID" HeaderText="TourID" />
<asp:BoundField DataField="FileName" HeaderText="FileName" SortExpression="FileName" />
<asp:BoundField DataField="StartDate" HeaderText="StartDate" SortExpression="StartDate" />
</Columns>
</asp:GridView>
</div>
<div class="col">
<asp:ListView ID="ListView1" runat="server" DataKeyNames="TourID" DataSourceID="dsTour">
<ItemTemplate>
<tr style="">
<td>
<asp:Label ID="TourIDLabel" runat="server" Text='<%# Eval("TourID") %>' />
</td>
<td>
<asp:Label ID="FileNameLabel" runat="server" Text='<%# Eval("FileName") %>' />
</td>
<td>
<asp:Label ID="StartDateLabel" runat="server" Text='<%# Eval("StartDate") %>' />
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table id="itemPlaceholderContainer" runat="server" border="0" style="">
<tr runat="server" style="">
<th runat="server">TourID</th>
<th runat="server">FileName</th>
<th runat="server">StartDate</th>
</tr>
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server" style=""></td>
</tr>
</table>
</LayoutTemplate>
</asp:ListView>
<br />
</div>
</div>
<ej:Grid ID="OrdersGrid" runat="server" AllowPaging="True" AllowSorting="True" /> <Columns> <ej:Column Field="OrderID" HeaderText=" Order ID" IsPrimaryKey="True" TextAlign="Right" Width="75"> <ValidationRule> <ej:KeyValue Key="required" Value="true" /> <ej:KeyValue Key="number" Value="true" /> </ValidationRule> </ej:Column> </Columns> <EditSettings AllowEditing="True" AllowAdding="True" AllowDeleting="True"></EditSettings> <ToolbarSettings ShowToolbar="True" ToolbarItems="add,edit,delete,update,cancel"></ToolbarSettings> </ej:Grid> <asp:SqlDataSource ID="SqlData" runat="server" ConnectionString="<%$ ConnectionStrings:NORTHWNDConnectionString %>" SelectCommand="SELECT * FROM [Orders]"></asp:SqlDataSource> </ContentTemplate> </asp:UpdatePanel> <ej:ListView ID="List" runat="server" ShowHeader="true" DataTextField="ShipCity" HeaderTitle="GridList" ShowHeaderBackButton="true" HeaderBackButtonText="Back" Height="450" Width="400"> </ej:ListView> Serverside:-
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["NORTHWNDConnectionString"].ToString());
dt = new DataTable("Order"); SqlCommand cmd = new SqlCommand();
cmd.Connection = myConnection;
cmd.CommandText = "select * from Orders";
cmd.CommandType = CommandType.Text;
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
if (myConnection.State == ConnectionState.Closed)
{
myConnection.Open();
}
da.Fill(dt);
Session["SqlDataSource"] = dt;
listdataBind();
}
griddataBind();
}
protected void griddataBind()
{
OrdersGrid.DataSource = (DataTable)Session["SqlDataSource"];
OrdersGrid.DataBind();
}
protected void listdataBind()
{
List.DataSource = Utils.DataTableToJson(dt);
List.DataBind();
} |