0

我有一列有很长的文本,我必须滚动到最后才能看到它。你能帮忙把内容安装在一个固定宽度的单元格中吗

用户界面:

 <asp:GridView ID="GridView1" runat="server" OnPageIndexChanging="PageIndexChanging_Click" 
                style="height: 166px; width: 217px; z-index: 1; left: 16px; top: 252px; position: absolute" 
                EmptyDataText="No Records Within this time Frame"  >
                <PagerSettings LastPageText="Last"  />
            </asp:GridView>

//Code Behind:   


    private void GetData()
            {
                string fromdata =  txt_fromdate.Text;//" '2013-09-23 11:06:00.077'";
                string todate =  txt_todata.Text;//" '2013-09-23 11:28:25.163' ";
                string querstring = "select * from gt_transaction_log where LogTimeStamp between" +"'"+ fromdata +"'"+ " and " +"'"+ todate + "'";
                SqlDataAdapter adapter = new SqlDataAdapter(querstring, conn);
                DataTable dt = new DataTable();
                GridView1.AllowPaging = true;
                if (TextBox1.Text != "" && int.Parse(TextBox1.Text) != 0)
                {
                    GridView1.PageSize = int.Parse(TextBox1.Text);
                }
                else
                { GridView1.PageSize = 10; }
                adapter.Fill(dt);
                GridView1.DataSource = dt;
                GridView1.DataBind();

            }
4

2 回答 2

0

你可以使用 CSS 来做到这一点:

.Grid{
height: 166px; width: 217px; z-index: 1; left: 16px; top: 252px; position: absolute
}
.Grid tr td{
   Width:100px;
}

  <asp:GridView ID="GridView1" runat="server" CssClass="Grid" OnPageIndexChanging="PageIndexChanging_Click" EmptyDataText="No Records Within this time Frame"></asp:GridView>

或者

  <asp:GridView ID="GridView1" runat="server" OnPageIndexChanging="PageIndexChanging_Click" 
                style="height: 166px; width: 217px; z-index: 1; left: 16px; top: 252px; position: absolute" AutoGenerateColumns="false"
                EmptyDataText="No Records Within this time Frame"  >
                    <Columns>
                        <asp:TemplateField HeaderText="Your column Name">
                            <ItemTemplate>
                                <%#Eval("EmployeeName") %>
                            </ItemTemplate>
                            <ItemStyle Width="50px" />


                        </asp:TemplateField>
                        .
                        .
                        .
                        .
                        Template fields for all columns of your datatable
                    </Columns>       
                <PagerSettings LastPageText="Last"  />
            </asp:GridView>
于 2013-09-24T21:04:32.953 回答
0

GridView 没有 Style 属性,但它有一个 CssClass 属性,您可以使用它来控制它的 CSS。

在样式块中创建 CSS:

<style type="text/css">
        .gridViewStyle {
            height: 166px;
                width: 217px; 
                z-index: 1; 
                left: 16px; 
                top: 252px; 
                position: absolute
        }
</style>

然后在您的 GridView 中,它将如下所示:

<asp:GridView CssClass="gridViewStyle" <!-- additional GV fields here -->>
</asp:Gridview>
于 2013-09-24T21:01:45.963 回答