Gridview问题(对我来说很复杂) [英] Gridview Problem (Complex [for me])

查看:105
本文介绍了Gridview问题(对我来说很复杂)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,这里遇到了问题.如您所见,我的gridview包含到目前为止我的数据库中所有数据,而即时消息仍使用滚动条,这是因为我的数据库记录很长.这是我的问题,是否有可能当我水平移动滚动条时,gridview的第一列保持不变,而第二列和其他列则向左移动.我的意思是我的第一列已设置好,以便当我修改gridview时,我可以看到即时修改的内容.我的第一列是标题.谢谢,还有更多功能

Hi guys, got a problem here. As you see my my gridview contains all the data from my database ans so far im using a scrollbar cause the records of my database is long. Heres my question, Is it possible that when i move my scrollbar horizontally the first column of the gridview stays while the second and the other columns moves to the left. I mean my first column is set so that when i modify the gridview i could see what im modifying with. My first column is the title. Thanks and more power

推荐答案

只需尝试以下操作:

受保护的void GridView1_RowDataBound(对象发送者,GridViewRowEventArgs e)
{
e.Row.Cells [0] .CssClass ="locked";
e.Row.Cells [1] .CssClass ="locked";
}


< title>无标题页面


div#div-datagrid {
宽度:220像素;
高度:100像素;
溢出:自动;
scrollbar-base-color:#ffeaff;
}

/*锁定左列*/
td.locked,th.locked {
字体大小:14像素;
font-weight:粗体;
文字对齐:居中;
背景颜色:海军;
颜色:白色;
右边框:1px纯银;
位置:相对;
光标:默认值;
/*仅适用于IE5 + */
左:expression(document.getElementById("div-datagrid").scrollLeft-2);
}

/*锁定表格标题*/
th {
字体大小:14像素;
font-weight:粗体;
文字对齐:居中;
背景颜色:海军;
颜色:白色;
右边框:1px纯银;
位置:相对;
光标:默认值;
/*仅适用于IE5 + */
顶部:expression(document.getElementById("div-datagrid").scrollTop-2);
z-index:10;
}

/*将标题保留为最上面的项目.对于左上方的项目很重要*/
锁定{z-index:99;}

/* DataGrid项目和AlternatingItem样式*/
.GridRow {font-size:10pt;颜色:黑色; font-family:Arial;
背景颜色:#ffffff;高度:35像素;}
.GridAltRow {font-size:10pt;颜色:黑色; font-family:Arial;
背景颜色:#eeeeee;高度:35像素;}









Just try this:

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
e.Row.Cells[0].CssClass = "locked";
e.Row.Cells[1].CssClass = "locked";
}


<title>Untitled Page


div#div-datagrid {
width: 220px;
height: 100px;
overflow: auto;
scrollbar-base-color:#ffeaff;
}

/* Locks the left column */
td.locked, th.locked {
font-size: 14px;
font-weight: bold;
text-align: center;
background-color: navy;
color: white;
border-right: 1px solid silver;
position:relative;
cursor: default;
/*IE5+ only*/
left: expression(document.getElementById("div-datagrid").scrollLeft-2);
}

/* Locks table header */
th {
font-size: 14px;
font-weight: bold;
text-align: center;
background-color: navy;
color: white;
border-right: 1px solid silver;
position:relative;
cursor: default;
/*IE5+ only*/
top: expression(document.getElementById("div-datagrid").scrollTop-2);
z-index: 10;
}

/* Keeps the header as the top most item. Important for top left item*/
th.locked {z-index: 99;}

/* DataGrid Item and AlternatingItem Style*/
.GridRow {font-size: 10pt; color: black; font-family: Arial;
background-color:#ffffff; height:35px;}
.GridAltRow {font-size: 10pt; color: black; font-family: Arial;
background-color:#eeeeee; height:35px;}










< asp:gridview datasourceid ="SqlDataSource1" id ="GridView1" runat ="server" onrowcreated ="GridView1_RowCreated" onrowdatabound ="GridView1_RowDataBound" xmlns:asp =#unknown">

<asp:gridview datasourceid="SqlDataSource1" id="GridView1" runat="server" onrowcreated="GridView1_RowCreated" onrowdatabound="GridView1_RowDataBound" xmlns:asp="#unknown">


这篇关于Gridview问题(对我来说很复杂)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆