These three question can not say in a word.
1.Use DataGrid Itemplate to solve it.
2.Use ViewState or Session or Cache to maintain it.
3.Use Js script to visit all DataItem and make it work.
1.Use DataGrid Itemplate to solve it.
2.Use ViewState or Session or Cache to maintain it.
3.Use Js script to visit all DataItem and make it work.
解决方案 »
- windowform的DataGridView
- 【请教大家】后台怎么给前台加input加onclick事件
- 导入Excel的问题,大家来看看啊。。
- (抢分了!!) 求救:安装discuz2.5时是老实说“未能加载文件或程序集“Discuz.Forum”或它的某一个依赖项”。。。
- rss系统 读取功能的代码 谁有 发来共享下
- 想要框架页显示部分的宽度为800,居中显示。如何解决?
- SQL Server9.0.1399和 SQL Server8.0.2039有什么区别?用9.0的在8.0能不能用?
- 根据路段获取地图对应的城市名
- 急急急!怎样在open出page中的服务器脚本中如何获得parent窗口中的服务器端控件的某个属性?
- 兄弟们啊,帮帮我啊,我的开发环境,问题
- 如何用sql语句获得最后一条记录的id号啊?
- 我建了一个virtual directory指向我数据库所在的文件夹,可用oledbconnection就是不知道怎么链上去?
还有,为什么不能加到300分?
你要等级达到4个▲才能放200分,300分要高级用户才能放,详细情况可以看csdn帮助
and Now I only can provide 200 to one post.
CheckBox mycheck=new CheckBox();
DataGrid.Items[行号].Cells[列号].Controls.Add(mycheck)以上代码您可以放在DataGrid的 ItemDataBound事件中2,3代码比较繁琐,我就不写了。
我已经另外再开了一百分来给呀!
你们可以查:
http://expert.csdn.net/Expert/topic/1229/1229008.xml?temp=.6768915
for exp:
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
CheckBox mycheck=new CheckBox();
e.Item.Cells["calculateColumn"].Controls.Add(mycheck)
}
请到这里领分!
谢谢你帮我!http://expert.csdn.net/Expert/topic/1229/1229098.xml?temp=.1082117
private void LoadData()
{
//调用接口
string CustUrl = System.Configuration.ConfigurationSettings.AppSettings["CustObjURL"];
ICustomer customer = (ICustomer)Activator.GetObject(typeof(ICustomer), CustUrl);
//登录ticket
FormsAuthenticationTicket ticket=((FormsIdentity)User.Identity).Ticket;
string userID=ticket.UserData;
//得到此用户的CUST_ID
customer.GetUser(userID,ref customerDS);
CustomerDataset.USERSRow userRow=(CustomerDataset.USERSRow)customerDS.USERS.Rows[0];
string custID=userRow.CUST_ID;
customer.GetUserSP(custID,ref customerDS);
//将customerDS存到Session中
Session["Hoten.Boss.CustInfoSys.Web.custinfo.serviceinfo.customerDS"] = customerDS;
}----------------------------------
private void BindGrid()
{
//从Session中得到customerDS
customerDS = (CustomerDataset)Session["Hoten.Boss.CustInfoSys.Web.custinfo.serviceinfo.customerDS"];
dataGridUserSP.DataBind();
int i;
for (i = dataGridUserSP.CurrentPageIndex * dataGridUserSP.PageSize;
i < (dataGridUserSP.CurrentPageIndex+1) * dataGridUserSP.PageSize && i < customerDS.USERS.Count;
i++)
{
DataGridItem rowItem = dataGridUserSP.Items[i%dataGridUserSP.PageSize];
string userID = customerDS.USERS[i].USER_ID;
DataList dataList = (DataList)rowItem.FindControl("DataList1");
foreach (DataListItem colItem in dataList.Items)
{
string spID = customerDS.SP[colItem.ItemIndex].SP_ID;
CheckBox check = (CheckBox)colItem.FindControl("CheckBox2");
//如果使用此SP,置相应checked为true,forecolor为red
check.Checked = customerDS.USER_SP.FindByUSER_IDSP_ID(userID, spID) != null;
check.ForeColor = customerDS.USER_SP.FindByUSER_IDSP_ID(userID, spID) != null? Color.Red : Color.Black;
}
}
}------------------------------------------------------------------
private void SaveData()
{
customerDS = (CustomerDataset)Session["Hoten.Boss.CustInfoSys.Web.custinfo.serviceinfo.customerDS"];
int i;
for (i = dataGridUserSP.CurrentPageIndex * dataGridUserSP.PageSize;
i < (dataGridUserSP.CurrentPageIndex+1) * dataGridUserSP.PageSize && i < customerDS.USERS.Count;
i++)
{
DataGridItem rowItem = dataGridUserSP.Items[i%dataGridUserSP.PageSize];
string userID = customerDS.USERS[i].USER_ID;
DataList dataList = (DataList)rowItem.FindControl("DataList1");
foreach (DataListItem colItem in dataList.Items)
{
string spID=customerDS.SP[colItem.ItemIndex].SP_ID;
CheckBox check=(CheckBox)colItem.FindControl("CheckBox2");
//
if((check.Checked) && (check.ForeColor==Color.Black))
{
customerDS.USER_SP.AddUSER_SPRow(userID, spID);
}
//
if((check.Checked==false) && (check.ForeColor==Color.Red))
{
customerDS.USER_SP.FindByUSER_IDSP_ID(userID, spID).Delete();
}
}
}
}//说明一点,如果进来的时候,该CheckBox就是选中的,我把它显示为红色!这样,第二次处理的时候,如果看到红色的就不做处理!!你想在殿“上一页”,“下一页”的时候保存,这样就行了:
private void dgUserSP_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
SaveData();
dataGridUserSP.CurrentPageIndex=e.NewPageIndex;
BindGrid();
}
希望能对你有些帮助!!:)
今天我去试试!
可以的话我就结贴(二百分)!