关于DATALIST传值问题 100分,在线等

gjchjw 2008-06-03 04:12:28
DATALIST2 是嵌套在DATALIST1里面的,用的ObjectDataSource 数据原控件,我DATALIST2的ObjectDataSource 要得到DATALIST1 里面的ID 获取方法是Control 是DATALIST1 的SelectedValue 但得不到DATALIST1里面的ID 也设了dataKey 为ID就是得不到,数据原控件得不到这个值吗?各位大侠帮忙啊
...全文
170 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
心情解码 2008-06-03
  • 打赏
  • 举报
回复
帮顶


-
gjchjw 2008-06-03
  • 打赏
  • 举报
回复
<td >
<asp:DataList ID="DataList1" runat="server" DataSourceID="ObjectDataSource1" DataKeyField="ID">
<ItemTemplate>
<asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' Visible="false" ></asp:Label><br />
试题名称:
<asp:Label ID="SS_IDLabel" runat="server" Text='<%# GetTitle(Eval("SS_ID")) %>'></asp:Label><br />
 <br />
<asp:DataList ID="DataList2" runat="server" DataSourceID="ObjectDataSource2">
<ItemTemplate>
<asp:Label ID="IDLabel1" runat="server" Text='<%# Eval("ID") %>' Visible="false" ></asp:Label>
<asp:RadioButton ID="RadioButton1" runat="server" GroupName="r1" />
<asp:Image ID="Image1" runat="server" />
<asp:TextBox ID="TextBox1" runat="server" Visible='<%# GetEnter(Eval("SSOEnter")) %>'></asp:TextBox>
</ItemTemplate>
</asp:DataList> 
</ItemTemplate>
</asp:DataList></td>
</tr>
<tr>
<td>
<asp:Button ID="Button1" runat="server" Text="保存" OnClick="Button1_Click" /></td>
</tr>
</table>

</div>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetAllStuChooseSingleBySQDID" TypeName="StuSingleDAL">
<SelectParameters>
<asp:SessionParameter Name="intSQDID" SessionField="SQDID" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
  
<asp:ObjectDataSource ID="ObjectDataSource2" runat="server" OldValuesParameterFormatString="original_{0}"
SelectMethod="GetAllStuSingleOptions" TypeName="StuSingleDAL">
<SelectParameters>
<asp:ControlParameter ControlID="DataList1" Name="intID" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
</form>

具体就是这样的
amandag 2008-06-03
  • 打赏
  • 举报
回复
贴贴你的页面代码(样式都不要),还有打算在什么事件中得到
wdx2008 2008-06-03
  • 打赏
  • 举报
回复
 protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Repeater wk = (Repeater)e.Item.FindControl("Repeater2");
DataRowView row = (DataRowView)e.Item.DataItem;
string pid = row["id"].ToString();
wk.DataSource =db.getDS(pid );//注意pid这里是Repeater1的主键值
wk.DataBind();
}
}


dalalist和Repeater类似,把控件名改过来就可以了
gjchjw 2008-06-03
  • 打赏
  • 举报
回复
1
gjchjw 2008-06-03
  • 打赏
  • 举报
回复
顶,帮忙啊,大哥们

110,571

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧