<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head id="Head1" runat="server">
<title></title>
<script src="Scripts/jquery.js" type="text/javascript"></script>
<script src="Scripts/colResizable-1.3.min.js" type="text/javascript"></script>
<script src="Scripts/jquery.cookie.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
if ($.cookie('colWidth') != null) {
var columns = $.cookie('colWidth').split(',');
var i = 0;
$('.GridViewStyle th').each(function () {
$(this).width(columns[i++]);
});
}
$(".GridViewStyle").colResizable({
liveDrag: true,
gripInnerHtml: "<div class='grip'></div>",
draggingClass: "dragging",
onResize: onSampleResized
});
});
var onSampleResized = function (e) {
var columns = $(e.currentTarget).find("th");
var msg = "";
columns.each(function () { msg += $(this).width() + ","; })
$.cookie("colWidth", msg);
};
</script>
</head>
<body>
<form id="Form1" runat="server">
<asp:Label ID="Label1" runat="server"></asp:Label>
<br /> <br />
<asp:GridView ID="GridView1" runat="server" CssClass="GridViewStyle">
</asp:GridView>
<br /><br />
<asp:Button ID="Button1" runat="server" Text="Test Postback" />
</form>
</body>
</html>
Code behind page
protected void Page_Load(object sender, System.EventArgs e)
{
Dictionary<string, int> col = new Dictionary<string, int>();
col.Add("key 1", 1);
col.Add("key 2", 2);
col.Add("key 3", 3);
col.Add("key 4", 4);
col.Add("key 5", 5);
GridView1.DataSource = col;
GridView1.DataBind();
}
protected void Button1_Click(object sender, System.EventArgs e)
{
Label1.Text = string.Format("Current Time is {0}", DateTime.Now.ToString());
}
Download the Source Code
No comments:
Post a Comment