GridView,repeater整理
来源:互联网 发布:淘宝卖家如何发布宝贝 编辑:程序博客网 时间:2024/05/20 19:19
Datalist数据绑定
普通:
<%# DataBinder.Eval(Container.DataItem, "itemName")%>或者 <%# Eval("topicContent")%>
A标签:
<a id="atopic" href="CarClubRemarkbefore.aspx?prodId=<%# Eval("prodId")%>" target="_self"></a>
图片:
<img border="0" height="50" src="<%# Eval("prodUrl")%>" width="50" />
按钮:
<asp:button id="btnbook" runat="server" text="加入购物车"
OnClientClick="javascript:return confirm('确认删除吗?')" commandname="book" commandargument='<%#Eval("prodId")%>' />
页面跳带参数跳转:
<input type="button" value=”详情" class="price_btn4" onclick="window.location='CarClubScenicDetail.aspx?prodId=<%# DataBinder.Eval(Container.DataItem, "prodId")%>&prodTypeId=<%# DataBinder.Eval(Container.DataItem, "prodTypeId")%>'" />
翻页插件:
AspNetPager.dll和chanagePage.css
gradview,repeater等获取选中行:
for (int i = 0; i < rpshopping.Items.Count; i++)
{
CheckBox cb = (CheckBox)rpshopping.Items[i].FindControl("cbbox");
//选?中D
if (cb.Checked)
{
int a = shoppingCarlst[i].collectId;
collects.Add(a);
TextBox ClassTitleTextBox = this.rpshopping.Items[i].FindControl("TextBox1") as TextBox;
string ClassTitle = ClassTitleTextBox.Text;
}
}
gridview 百分比:
<asp:templatefield headertext="佣金百分比">
<ItemTemplate>
<%#Eval("CSL_Percent").ToString() + "%"%>
</ItemTemplate>
</asp:templatefield>
GridView绑定实体类的子实体的字段:
表user生成的实体User里包含子实体Role想要绑定RoleName
可以使用如下进行绑定:
<%# (((User)Container.DataItem).Role).RoleName %>
取gridview对应列数据:
string a = this.GridView1.Rows[i].Cells[j].Text.ToString();
textbox.text = a;
通过aspnetpager为DataList分页(插件AspNetPager.dll,chanagePage.css在资源中下载):
前台代码:
<div id="newslistdiv">
<asp:DataList ID="rtBusOrder" runat="server" Width="820px">
<HeaderTemplate>
</ItemTemplate> </asp:DataList> </div>
<div>
<webdiyer:AspNetPager ID="AspNetPager1" CssClass="paipai" CurrentPageButtonClass="cpb"
runat="server" PageSize="9" FirstPageText=" 首页" LastPageText=" 尾页" NextPageText=" 下一页"
OnPageChanged="AspNetPager1_PageChanged" PrevPageText=" 上?一?页? " AlwaysShow="true">
</webdiyer:AspNetPager>
</div>
后台代码:
//翻页代码
this.AspNetPager1.RecordCount = UserOrderAll.Count;
PagedDataSource pds = new PagedDataSource(); //定义一个PagedDataSource类来执行分页功能
pds.DataSource = UserOrderAll;
pds.AllowPaging = true;
pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
pds.PageSize = AspNetPager1.PageSize;
AspNetPager1.CurrentPageButtonPosition = Wuqi.Webdiyer.PagingButtonPosition.Center;
//绑定表
rtBusOrder.DataSource = pds;
rtBusOrder.DataBind();
GridView的RowDataBound事件:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//隐藏列
if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Header)
{
e.Row.Cells[0].Visible = false;
}
//执行循环,保证每条数据都能更新
if (e.Row.RowType == DataControlRowType.DataRow)
{
//当鼠标停留时更改背景色
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#00A9FF'");
//当鼠标移开时还原背景色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
//鼠标放上时是小手指
e.Row.Attributes["style"] = "cursor:hand";
//点击鼠标打开页面
e.Row.Attributes.Add("onclick", "window.open('CompanyUpdate.aspx?CompanyID=" + e.Row.Cells[0].Text.ToString() + "','newwindow','toolbar =no, menubar=no, scrollbars=no, resizable=yes, location=no, status=no,top=280,left=450,width=1000,height=500')");
}
if (e.Row.RowState == DataControlRowState.Edit)
{ //编辑状态
e.Row.Attributes.Remove("onclick");
e.Row.Attributes.Remove("ondblclick");
e.Row.Attributes.Remove("style");
e.Row.Attributes["title"] = "编辑行";
}
}
- GridView,repeater整理
- GridView 、DataList 、Repeater 比较
- GridView、ListView、Repeater使用方法
- Gridview repeater datelist 区别
- GridView、Repeater合并单元格
- Gridview ,repeater,datalist 通用分页
- Gridview ,repeater,datalist 通用分页
- GridView中嵌套Repeater方法
- Gridview、Datalist、Repeater,选哪个?
- repeater和gridview的行号
- gridview,datalist,repeater控件使用
- GridView中嵌套Repeater方法
- GridView、Repeater获取当前行号
- GridView,DataList,Repeater日期输出
- 自己写Repeater/GridView分页
- Repeater和Gridview的区别
- Repeater和Gridview的区别
- gridview , listview , repeater自动行号
- 13-mysql中的命令
- 错位字符串
- struts2学习(7)——常量的配置
- POJ1159 Palindrome(最大回文串长度)
- HDU 4602 FFT 终于大致会用FFT了。。
- GridView,repeater整理
- 内部类
- 核心文件&核心转储
- 单例模式
- 黑马程序员——String、StringBuffer、StringBuilder三兄弟
- PHP调试工具Xdebug安装配置教程
- Poj 3292(筛法变形)
- hdu 4605 Magic Ball Game
- JavaScript 框架页面互相访问