作者:mbe5757086 | 来源:互联网 | 2023-05-17 09:54
IvegotanASP.NetprojectwithC#andhaveaRepeaterControlonanaspxpagethatbuildsupanht
I've got an ASP.Net project with C# and have a Repeater Control on an aspx page that builds up an html table by iterating over a datasource. I want to use the JQuery Flexigrid plug-in to make the table scrollable, but have been unable to figure out how to make it work due to lack of documentation on the plug-in. Does anyone know how to do this, or have sample code to share?
我有一个带有C#的ASP.Net项目,并在aspx页面上有一个Repeater Control,它通过遍历数据源来构建一个html表。我想使用JQuery Flexigrid插件使表格可滚动,但由于缺少插件文档而无法弄清楚如何使其工作。有谁知道如何做到这一点,或有示例代码分享?
3 个解决方案
I have never used Flexigrid myself however after looking at the samples on the site I'll offer my suggestions.
我自己从未使用过Flexigrid,但在查看网站上的示例后,我会提供我的建议。
It looks like what you need to create with your repeater is a properly formatted html table with at least a thead and tbody section.
看起来你需要用你的转发器创建的是一个格式正确的html表,至少有一个thead和tbody部分。
header1 |
header2 |
table data 1 |
table data 2 |
Once done, making a simple call to the following should create the Flexigrid table with the default settings:
完成后,对以下内容进行简单调用应该使用默认设置创建Flexigrid表:
$("#mytable").flexigrid();
From there you can pass in what looks to be a ton of options to make it look as pretty as you want.
从那里你可以传递看起来很多选项,使它看起来像你想要的漂亮。
As for the repeater itself, there are a bunch of ways to set it up depending on what you need. Probably the simplest way is as follows:
至于转发器本身,有很多方法可以根据您的需要进行设置。可能最简单的方法如下:
And your data bind event would look something like this:
你的数据绑定事件看起来像这样:
public void myrepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
myDataObject = e.Item.DataItem;
Label data1 = e.Item.FindControl("data1");
Label data2 = e.Item.FindControl("data2");
data1.Text = myDataObject.data1;
data2.Text = myDataObject.data2;
}