DataGrid 查找控件
嗨,
我有一个 DataGrid (是的,如果它是一个 gridview 会更好,但我对此无能为力)
在 itemDataBound 事件中我在每行的第一个单元格中添加一个隐藏字段 我根据某些内容设置其 ID,然后将其 clientID 保存在列表中,以便稍后尝试从中获取值,
但尝试使用 findcontrol 找不到任何内容,
尝试过
这里是 itemdatabound 位
foreach(page in datasource){
HiddenField hidOrder = new HiddenField();
hidOrder.ID = "order_" + page.Id.ToString();
hidOrder.Value = page.Ordering.ToString();
e.Item.Cells[0].Controls.Add(hidOrder);
idList.Add(hidOrder.ClientID);
}
,然后这是一个按钮单击活动..
int numRows = FrontEndDataGrid.Items.Count;
for (int i = 0; i < numRows; i++){
foreach(string hidID in idList){
HiddenField hf = FrontEndDataGrid.Items[i].FindControl(hidID) as HiddenField;
//ssadly this never finds anything
//have also tried looping around the cells for each 'row' - no luck there either
}
}
有什么想法吗?
谢谢纳特
HI
I have a DataGrid (yes would be nicer if it was a gridview but nothing i can do about that)
in the itemDataBound event i am adding a hidden field into the first cell of each row
I am setting its ID based on something, and then saving its clientID in a List for later attempts to get the value from it
but try as i might i cant find anything with findcontrol
have tried
here is the itemdatabound bit
foreach(page in datasource){
HiddenField hidOrder = new HiddenField();
hidOrder.ID = "order_" + page.Id.ToString();
hidOrder.Value = page.Ordering.ToString();
e.Item.Cells[0].Controls.Add(hidOrder);
idList.Add(hidOrder.ClientID);
}
then this is a button click event..
int numRows = FrontEndDataGrid.Items.Count;
for (int i = 0; i < numRows; i++){
foreach(string hidID in idList){
HiddenField hf = FrontEndDataGrid.Items[i].FindControl(hidID) as HiddenField;
//ssadly this never finds anything
//have also tried looping around the cells for each 'row' - no luck there either
}
}
any ideas?
thanks
nat
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,看来我有 clientID ,并且我需要普通 id
所以更改了 idList.Add(hidOrder.ID);
一切都很好
ok it seems i had the clientID , and i need the the plain id
so changed the idList.Add(hidOrder.ID);
and all is well