Checkbox在gridview中,然后在checkbox.checked时填充另一个gridview [英] Checkbox In gridview then fill another gridview when checkbox.checked
问题描述
你好
我需要协助.我有一个网格视图,该视图从数据库中提取了一些信息,并将其绑定到了网格视图.那个很好.
现在我在gridview中有一个复选框,当Checkbox.checked选中时,它应该转移到另一个gridview中,最后我可以通过一个按钮将其保存到数据库中(想使用LinQ).
我的问题是,如果已经拥有第二个gridview,该如何填充?
收合|复制代码
Hello
I need some help. I have a Grid view that is pulling some information from the Database and its bound to the gridview. That is working Fin.
Now I have a checkbox in the gridview that when Checkbox.checked it should transfer to another gridview where I can finally save it to de database with a button (thinking to use LinQ).
My Question is how can I fill the second gridview if I have this already?
Collapse | Copy Code
//List<int> purchaseProductList = new List<int>();
for (int i = 0; i < ProductGridView.Rows.Count; i++)
{
int productId = (int)ProductGridView.DataKeys[i][0];
CheckBox cb = (CheckBox)ProductGridView.Rows[i].FindControl("CheckBoxPurchase");
if (cb.Checked)
{
purchaseProductList.Add(productId);
}
}
在这里,我真的不知道要输入什么代码,因为我不想使用数据表,应该是linQ}
//
//
Here I dont really know what code to put since I dont want to use datatable, should be linQ }
//
//
推荐答案
您的意思是应该是LINQ"?使用任何适合的方法-您的数据来自哪里? LINQ如何更好?它给你什么?这是否意味着当有人选中该框时您必须进行回发吗?
为什么要让它工作,而不是更在乎自己怎么做(客户端甚至看不到)?
What do you mean ''should be LINQ'' ? Use whatever suits - where does your data come from ? How is LINQ preferable ? What does it give you ? Does this mean that you have to do a postback when someone checks the box ?
Why do you care more about how you do it ( which the client can''t even see ), than getting it to work ?
这篇关于Checkbox在gridview中,然后在checkbox.checked时填充另一个gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!