我正在尝试使用水平滚动条和垂直滚动条(例如sql表)构建gridview。目前,我所拥有的表非常基本,它看起来并不整齐,我担心随着列数的增加,gridview看起来会更加混乱。我附上两个截图,说明我当前的gridview是如何以及另一个我想如何构建我的gridview.Any建议或建议真的很感激。
C#
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DataTable tblcsv = new DataTable();
//creating columns
tblcsv.Columns.Add("Transaction_date");
tblcsv.Columns.Add("Product");
tblcsv.Columns.Add("Price");
tblcsv.Columns.Add("Payment_Type");
tblcsv.Columns.Add("Name");
tblcsv.Columns.Add("City");
tblcsv.Columns.Add("State");
tblcsv.Columns.Add("Country");
tblcsv.Columns.Add("Account_Created");
tblcsv.Columns.Add("Last_Login");
tblcsv.Columns.Add("Latitude");
tblcsv.Columns.Add("Longitude");
tblcsv.Columns.Add("Data");
tblcsv.Columns.Add("a");
tblcsv.Columns.Add("b");
tblcsv.Columns.Add("c");
tblcsv.Columns.Add("d");
tblcsv.Columns.Add("e");
tblcsv.Columns.Add("f");
tblcsv.Columns.Add("g");
tblcsv.Columns.Add("h");
tblcsv.Columns.Add("i");
tblcsv.Columns.Add("j");
tblcsv.Columns.Add("k");
//getting full file path of Uploaded file
//Reading All text
string ReadCSV = File.ReadAllText(Server.MapPath("~/c.csv"));
//spliting row after new line
foreach (string csvRow in ReadCSV.Split('\n'))
{
if (!string.IsNullOrEmpty(csvRow))
{
//Adding each row into datatable
tblcsv.Rows.Add();
int count = 0;
foreach (string FileRec in csvRow.Split(','))
{
tblcsv.Rows[tblcsv.Rows.Count - 1][count] = FileRec;
count++;
}
}
//Calling Bind Grid Functions
Bindgrid(tblcsv);
}
}
private void Bindgrid(DataTable csvdt)
{
GridView1.DataSource = csvdt;
GridView1.DataBind();
}
}
aspx -
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" width="300px" AllowSorting="True">
</asp:GridView>
</div>
</form>
</body>
</html>
答案 0 :(得分:0)
你可以使用css,例如&#34;溢出&#34;以下使用的财产。
table{
height:500px;
width:1000px;
overflow-x:scroll;
overflow-y:scroll;
}
&#13;
<table>
<thead>
<th>ID</th>
<th>FirstName</th>
<th>LastName</th>
</thead>
<tbody>
<tr>
<td>1</td>
<td>joe</td>
<td>Lobo</td>
</tr>
<tr>
<td>1</td>
<td>joe</td>
<td>Lobo</td>
</tr>
<tr>
<td>1</td>
<td>joe</td>
<td>Lobo</td>
</tr>
<tr>
<td>1</td>
<td>joe</td>
<td>Lobo</td>
</tr>
<tr>
<td>1</td>
<td>joe</td>
<td>Lobo</td>
</tr>
</tbody>
</table>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
&#13;
https://www.w3schools.com/cssref/pr_pos_overflow.asp
https://www.w3schools.com/cssref/css3_pr_overflow-x.asp
https://www.w3schools.com/cssref/css3_pr_overflow-y.asp
答案 1 :(得分:0)
试试这个:
<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="AppBundle\Entity\ExtensionSyliusShopUser" table="extension_sylius_shop_user">
<indexes>
<index name="user_id" columns="user_id"/>
</indexes>
<id name="id" type="integer" column="id">
<generator strategy="IDENTITY"/>
</id>
<field name="wishlist" type="text" column="wishlist" length="65535" nullable="true">
<options>
<option name="fixed"/>
</options>
</field>
<many-to-one field="user" target-entity="SyliusShopUser" fetch="LAZY">
<join-columns>
<join-column name="user_id" referenced-column-name="id"/>
</join-columns>
</many-to-one>
</entity>
</doctrine-mapping>