*****datalist问题

rabies 2003-08-20 01:09:31
在datalist里加入了一个Button还有一个Dropdownlist
如何在Button按下之后获得Dropdownlist的值

int quantity =((DropDownList)ProductDataList.Items[1].FindControl("QuantityDropDownList")).SelectedIndex+1;

但是item[i]怎么获得?
触发的是Clickonbutton

如果不这么做,有没有其他办法?

谢谢大家
...全文
49 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
rabies 2003-08-20
  • 打赏
  • 举报
回复
怎么用ButtonColumn呢,有没有例子啊
谢谢大家了:)
rabies 2003-08-20
  • 打赏
  • 举报
回复
up...
cnhgj 2003-08-20
  • 打赏
  • 举报
回复
用ButtonColumn,然后调用ITEMCOMMAND事件,接着就跟思归大侠说的那样了
cnhgj 2003-08-20
  • 打赏
  • 举报
回复
加入asp:ButtonColumn,然后调用OnItemCommand事件,接着的就跟思归大侠说的那样了
rabies 2003-08-20
  • 打赏
  • 举报
回复
To saucer(思归, .NET MVP)

不可以啊
因为我是使Button触发事件,
如果给Datalist加了这个事件则根本不会触发啊

To jjcccc()
试过了,但由于是Button触发事件 SelectedItem根本好像就没有
jjcccc 2003-08-20
  • 打赏
  • 举报
回复
==>
int quantity =((DropDownList)ProductDataList.SelectedItem.FindControl("QuantityDropDownList")).SelectedIndex+1;
saucer 2003-08-20
  • 打赏
  • 举报
回复
add an ItemCommand handler for the DataList, then try

void DataList_ItemCommand(Object sender, DataListCommandEventArgs e)
{
int quantity =((DropDownList)e.Item.FindControl("QuantityDropDownList")).SelectedIndex+1;
}

110,529

社区成员

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

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

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