*****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

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

谢谢大家
...全文
50 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;
}
/** * 查询全国所有的省,优先从数据库查询,如果没有查询到再去服务器上查询。 */ private void queryProvinces() { provinceList = coolWeatherDB.loadProvinces(); if (provinceList.size() > 0) { dataList.clear(); for (Province province : provinceList) { dataList.add(province.getProvinceName()); } adapter.notifyDataSetChanged(); listView.setSelection(0); titleText.setText("中国"); currentLevel = LEVEL_PROVINCE; } else { queryFromServer(null, "province"); } } /** * 查询选中省内所有的市,优先从数据库查询,如果没有查询到再去服务器上查询。 */ private void queryCities() { cityList = coolWeatherDB.loadCities(selectedProvince.getId()); if (cityList.size() > 0) { dataList.clear(); for (City city : cityList) { dataList.add(city.getCityName()); } adapter.notifyDataSetChanged(); listView.setSelection(0); titleText.setText(selectedProvince.getProvinceName()); currentLevel = LEVEL_CITY; } else { queryFromServer(selectedProvince.getProvinceCode(), "city"); } } /** * 查询选中市内所有的县,优先从数据库查询,如果没有查询到再去服务器上查询。 */ private void queryCounties() { countyList = coolWeatherDB.loadCounties(selectedCity.getId()); if (countyList.size() > 0) { dataList.clear(); for (County county : countyList) { dataList.add(county.getCountyName()); } adapter.notifyDataSetChanged(); listView.setSelection(0); titleText.setText(selectedCity.getCityName()); currentLevel = LEVEL_COUNTY; } else { queryFromServer(selectedCity.getCityCode(), "county"); } }

110,534

社区成员

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

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

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