固定头+水平滚动,dsta在gridview中滚动 [英] Fixedheader+horizontal scrolling with dsta scrolling in gridview
问题描述
亲爱的朋友们
i希望修复标题horizontol滚动数据vartical scroll我用这个编码完成了它
in desing
Dear Frinds
i want fix header horizontol scroll with data vartical scroll and i have done it with this coding
in desing
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="fixheadersrollable._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
<script src="http://code.jquery.com/jquery-1.7.1.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript" >
function MakeStaticHeader(gridId, height, width, headerHeight, isFooter) {
var tbl = document.getElementById(gridId);
if (tbl) {
var DivHR = document.getElementById('DivHeaderRow');
var DivMC = document.getElementById('DivMainContent');
var DivFR = document.getElementById('DivFooterRow');
//*** Set divheaderRow Properties ****
DivHR.style.height = headerHeight + 'px';
DivHR.style.width = (parseInt(width) - 16) + 'px';
DivHR.style.position = 'relative';
DivHR.style.top = '0px';
DivHR.style.zIndex = '10';
DivHR.style.verticalAlign = 'top';
//*** Set divMainContent Properties ****
DivMC.style.width = width + 'px';
DivMC.style.height = height + 'px';
DivMC.style.position = 'relative';
DivMC.style.top = -headerHeight + 'px';
DivMC.style.zIndex = '1';
//*** Set divFooterRow Properties ****
DivFR.style.width = (parseInt(width) - 16) + 'px';
DivFR.style.position = 'relative';
DivFR.style.top = -headerHeight + 'px';
DivFR.style.verticalAlign = 'top';
DivFR.style.paddingtop = '2px';
if (isFooter) {
var tblfr = tbl.cloneNode(true);
tblfr.removeChild(tblfr.getElementsByTagName('tbody')[0]);
var tblBody = document.createElement('tbody');
tblfr.style.width = '100%';
tblfr.cellSpacing = "0";
tblfr.border = "0px";
tblfr.rules = "none";
//*****In the case of Footer Row *******
tblBody.appendChild(tbl.rows[tbl.rows.length - 1]);
tblfr.appendChild(tblBody);
DivFR.appendChild(tblfr);
}
//****Copy Header in divHeaderRow****
DivHR.appendChild(tbl.cloneNode(true));
}
}
function OnScrollDiv(Scrollablediv) {
document.getElementById('DivHeaderRow').scrollLeft = Scrollablediv.scrollLeft;
document.getElementById('DivFooterRow').scrollLeft = Scrollablediv.scrollLeft;
}
</script>
<script type="text/javascript" onload="setvalue();">
function getvalue(Scrollablediv) {
sessionStorage.setItem('pediv1', document.getElementById('DivMainContent').scrollTop);
sessionStorage.setItem('pediv2', document.getElementById('DivMainContent').scrollLeft);
OnScrollDiv(Scrollablediv)
}
function setvalue() {
// alert(sessionStorage.getItem('pediv1'));
// alert(sessionStorage.getItem('pediv2'));
document.getElementById('DivMainContent').scrollTop = sessionStorage.getItem('pediv1');
document.getElementById('DivMainContent').scrollLeft = sessionStorage.getItem('pediv2');
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:Button ID="as" runat="server" Text="PostBack" />
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div id="DivRoot" align="left">
<div style="overflow: hidden;" id="DivHeaderRow">
</div>
<div style="overflow:scroll; " onscroll="getvalue(this)" id="DivMainContent" runat="server" >
<%-- Place Your GridView Here
<asp:GridView runat="server" ID="gridshow" Width="100%" AutoGenerateColumns="False"ShowFooter="True">
<Columns>
//...................
</Columns>
</asp:GridView>
--%>
<asp:GridView ID="aa" runat="server" >
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="lable1" runat="server" Text='<%# Bind("Id") %>' Visible="false"></asp:Label>
<asp:TextBox ID="txtitem" runat="server" AutoPostBack="true"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<div id="DivFooterRow" style="overflow:hidden">
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:VideoconConnectionString %>"
SelectCommand="SELECT * FROM [PR_GRNDetails]"></asp:SqlDataSource>
</div>
</div>
</form>
</body>
</html>
和代码背后
and code behind
Partial Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
ScriptManager.RegisterStartupScript(Page, Me.GetType(), "Key", "<script>MakeStaticHeader('" + aa.ClientID + "', 500, 550 , 40 ,true,'details'); </script>", False)
'ScriptManager.RegisterStartupScript(Page, Me.GetType(), "Key1", "<script>MakeStaticHeader('" + aa.ClientID + "', 500, 550 , 40 ,true,'details1'); </script>", False)
If Not IsPostBack Then
aa.DataSource = SqlDataSource1
aa.DataBind()
For i As Int16 = 0 To aa.Rows.Count - 1
CType(aa.Rows(i).FindControl("txtitem"), TextBox).Text = ""
'CType(aa.Rows(i).FindControl("txtitem"), TextBox).Text = CType(aa.Rows(i).FindControl("lable1"), Label).Text
Next
End If
End Sub
End Class
但问题是我有一个文本框在网格中它的autopostback是真的,当它回发时有多个条目用逗号23,23,23请帮助我
but problem is that i have a text box in grid and its autopostback true when it is post back thanit have multiple entry with comma 23,23,23 pls help me
推荐答案
ConnectionStrings:VideoconConnectionString %>
SelectCommand = SELECT * FROM [PR_GRNDetails] > < / asp:SqlDataSource >
< / div >
< / div >
< / form >
< / body >
< / html >
ConnectionStrings:VideoconConnectionString %>" SelectCommand="SELECT * FROM [PR_GRNDetails]"></asp:SqlDataSource> </div> </div> </form> </body> </html>
和代码背后
and code behind
Partial Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
ScriptManager.RegisterStartupScript(Page, Me.GetType(), "Key", "<script>MakeStaticHeader('" + aa.ClientID + "', 500, 550 , 40 ,true,'details'); </script>", False)
'ScriptManager.RegisterStartupScript(Page, Me.GetType(), "Key1", "<script>MakeStaticHeader('" + aa.ClientID + "', 500, 550 , 40 ,true,'details1'); </script>", False)
If Not IsPostBack Then
aa.DataSource = SqlDataSource1
aa.DataBind()
For i As Int16 = 0 To aa.Rows.Count - 1
CType(aa.Rows(i).FindControl("txtitem"), TextBox).Text = ""
'CType(aa.Rows(i).FindControl("txtitem"), TextBox).Text = CType(aa.Rows(i).FindControl("lable1"), Label).Text
Next
End If
End Sub
End Class
但问题是我有一个文本框在网格中,并且当它回发时它的自动回复是真的,因为它有多个带逗号的条目23,23,23请帮助我
but problem is that i have a text box in grid and its autopostback true when it is post back thanit have multiple entry with comma 23,23,23 pls help me
这篇关于固定头+水平滚动,dsta在gridview中滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!