1,gridview 的数据显示与更新
DataSet ds=new DataSet()…………
this.gridview1.datasource=ds.tables[0].defaultview;
设置DataKeyNames 主键,与数据列名
更新时获得原数据:string str=this.gridview1.DataKeyNames[e.RowIndex][0].tostring();
tb中的数据:string str=((textbox)this.gridview1.Rows[e.index].Cells[0].Controls[0]).Text.tostring();
2,repeater & datalist
在itemtemplate中获取绑定数据源(DS)的条目:<%# DataBinder.Eval(Container.DataItem,"列名") %>
<%# Eval(" column name")%>
<
遍历每一项:foreach(datalistItem dli in datalist.items)
{
checkbox cb=(checkbox)dli.findcontrol("控件ID")
}
点击列中的linkbutton
添加onclick事件即可
首先<asp:linkbutton ].ToString();
}
if (((LinkButton)e.CommandSource).CommandName== "reject")
{
Response.Write("reject");
}
}
}
分页:
int currentindex = onvert.ToInt32(this.lblcurrentpage.Text);
pds.DataSource = ds.Tables[0].DefaultView;
pds.AllowPaging = true;
pds.PageSize = 3;
this.lblpagecount.Text = pds.PageCount;
pds.CurrentPageIndex = currentindex;