在asp.net ajax web应用程序中的radgrid的NeedDatasource事件中获取下拉列表中选定的值
我想在选择时从下拉列表中获取值。在该值的选择上,我将触发一个简单的选择查询,即。
"select * from Category where cat_name ='" + dropdownlistselectedvalue + "'"
的代码
这里是 needDatasource protected void rdgridview_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e) { if (!e.IsFromDetailTable) {
//我想在此处获取下拉列表所选值,即
string dpvalue = DropDownList1.SelectedValue.ToString();
string strqry = "select * from Categories where Category_Name = '"+ dpvalue +"'";
rdgridview.DataSource = getDataTable(strqry);
}
}
但我无法从 needDatasource 方法中的下拉列表所选值中获取值。我该如何获取下拉列表控件的值或触发任何事件?
提前致谢
I want to fetch value from dropdownlist when selected. On that selection of value I am firing a simple select query ie.
"select * from Category where cat_name ='" + dropdownlistselectedvalue + "'"
here is the code of needDatasource
protected void rdgridview_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
if (!e.IsFromDetailTable)
{
//I want to fetch the dropdownlist selected value here ie
string dpvalue = DropDownList1.SelectedValue.ToString();
string strqry = "select * from Categories where Category_Name = '"+ dpvalue +"'";
rdgridview.DataSource = getDataTable(strqry);
}
}
But I am not able to fetch the value from the dropdownlist selected value in needDatasource method. How shall I fetch the value or fire any event of dropdownlist control?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Telerik 有详细的文档。您可能想尝试简单的数据绑定。请在此处查看。
有关 NeedsDataSource 文档,请查看此处。
Telerik has a detailed documentation. You might want to try simple data binding. Check it here.
For NeedsDataSource documentation, check here.
您可以通过将下拉列表选定的值保存在
ViewState
中来轻松完成此操作,并在 dropdownlist 的SelectedIndexChanged
事件中执行此操作。然后在
needDatasource
事件中从ViewState
获取值:You can do that easily by saving the dropdownlist selected value in a
ViewState
, do that in theSelectedIndexChanged
event for the dropdownlist .then get the value from
ViewState
in theneedDatasource
event: