如何从.net中的子数据列表获取父数据列表值 [英] How to get parent datalist value from child datalist in .net

查看:136
本文介绍了如何从.net中的子数据列表获取父数据列表值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个数据列表

子数据列表是基于父数据列表值(categoryid)进行绑定的.我已经在父数据列表itemdatabound中完成了.

现在问题出在子数据列表editcommand上,在e.edititemindex之后,我需要绑定子数据列表.为此,我需要父数据列表值(categoryid).

我不知道该怎么得到....

解决方案

最简单的方法是获取Parent-CategoryId以及子数据列表的其他值,并在显示时将其隐藏.这将需要在查询中进行很小的更改,而在显示时几乎不需要更改.
这样,您在选择子记录时将始终拥有父值以及其他子行值.


感谢您的重放.是的,我已经这样做了.

将一个隐藏的文件放在子数据列表中,另一个隐藏在父数据列表中

照常使用Eval和
绑定父隐藏字段的值
然后在子数据列表itemdatabound上,将该隐藏字段值分配给子数据列表隐藏字段

现在我得到了价值...

谢谢


@hygeenams

我试图在子数据列表中找到关联的父数据键,以便我可以在子数据列表中使用它,但可以实现您的way.plas代码帮助.我想在单击子数据列表编辑命令按钮时获取父数据键值. /blockquote>

I have 2 datalist

child datalist is binding based on parent datalist value(categoryid).That i have done in parent datalist itemdatabound.

now the issue is on child datalist editcommand ,after e.edititemindex i need to bind child datalist.for that i need parent datalist value(categoryid).

I have no idea how to get this....

do u have any suggestions?

解决方案

Easiest would be to fetch Parent-CategoryId along with other values of child datalist and keep it as hidden while display. This would need small change in query and little change while display.

This way you will always have parent value at the selection of child record with other child row values.


Thank u for replay.yes i have done like that.

put one hidden filed in child datalist and one in parent

Bind parent hidden filed value as usual using Eval and

then on child datalist itemdatabound,assigned that hidden field value to child datalist hidden field

Now i got the value...

Thanks


@hygeenams

i am trying to find the parent datakey associated in child datalist so that i can use it in child datalist but can implement ur way.plase help with codes.i want to get the parent datakey value when child datalist edit command button is clicked.


这篇关于如何从.net中的子数据列表获取父数据列表值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆