- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 ASP 中有一个 gridview
,具有包含 select
、edit
和 delete 的
链接每一行,页脚包含 template Fields
insert
链接。
每行有两个dropdownlists
,比方说:Category
和sub-category
,当我改变的内容时category DropDownList
sub-category DropDownList
应该自动显示相应的内容。
我已经尝试编写一个 onSelectedIndexChanged
处理程序,但我不知道如何继续。 有什么想法吗? (请记住,我使用了所有 rowDataBound() 代码来填充下拉列表)
换句话说,如何填充 row_databound() 以外的下拉列表
代码:
protected void grdBulkScheduler_RowDataBound(object sender, GridViewRowEventArgs e)
{
try
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DropDownList ddlCategory = (DropDownList)e.Row.FindControl("ddlCategory");
if (ddlCategory != null)
{
ddlCategory .DataSource = cData.GetCategory();
ddlCategory .DataValueField = "c_ID";
ddlCategory .DataTextField = "c_Text";
ddlCategory .DataBind();
}
在这里,我从 GridViewRowEventArgs
中找到下拉列表 category在 selectedIndexChanged 处理程序中,如何找到 DropDownList? 因为 DropDownList ddlCategory = (DropDownList)e.Row.FindControl("ddlCategory")
不工作
最佳答案
听起来您想使用您在类别下拉列表中选择的值将数据绑定(bind)到子类别下拉列表。你可以这样做:
protected void ddlCategory_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewRow row = (GridViewRow)((DropDownList)sender).Parent.Parent;
DropDownList ddlSubCategory = (DropDownList)row.FindControl("ddlSubCategory");
ddlSubCategory.DataSource = //whatever you want to bind, e.g. based on the selected value, using((DropDownList)sender).SelectedValue;
ddlSubCategory.DataBind();
}
如果我误解了你,请在评论中纠正我。
关于c# - ASP Gridview 下拉列表选择已更改,如何填充 rowDataBound() 以外的下拉列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16737372/
我有 2 个 Gridview。第一个网格有一个按钮,当单击该按钮时,它将使用基于所单击按钮的 ID 的数据填充第二个网格。 然后我在 RowDataBound 函数中添加了代码,以根据所选行显示网格
我希望有人能帮帮忙!我有一个具有 gridview 的用户控件(UC 中有一个更新面板) 我在 2 个不同的页面上使用这个 UC - 在这两个页面上,UC 都位于一个选项卡(ajax tabpanel
我有一个 gridview,如果选择了某个下拉列表项,我只想允许编辑文本框。在我的 RowDataBound 中,我得到了值并决定是否应该对其进行编辑,但是 .Visible 属性没有像我预期的那样工
我需要在事件 rowdatabound 中找到 gridview 中的总列数。有什么办法吗?下面是我的一些代码: protected void gvEmployee_RowDataBound(o
在 ASP.NET 页面上,我有一个填充了 LINQ 查询结果的 GridView。我在代码中设置 DataSource,然后对其调用 DataBind。在 GridView 的 RowDataBou
我有一个 rowdatabound 方法,它对两个 gridviews 是通用的。此方法的部分任务是将值分配给 GridView 的最后一列。 gridviews是一样的,但是两个gridviews的
我需要在 GridView 的 rowdatabound 事件的 DataControlRowType.Data 中获取列标题,我是这样做的: ((DataTable)((GridView)sende
我有一个 rowdatabound 方法,它对两个 gridviews 是通用的。此方法的部分任务是将值分配给 GridView 的最后一列。 gridviews是一样的,但是两个gridviews的
我有一个匿名类型的 GridView。我需要检查单元格中的值并在满足条件时突出显示该单元格。问题是,当我尝试从行的单元格中提取数据时,总是得到一个空字符串。我已成功突出显示所有单元格,并且已在 Vis
我可以在 GridView 中编辑单行。 但是,当在 MySQL 数据库中,字段 "card" 的值不为空时,我需要停止 GridView 的这一行中的编辑(并将该行传递到关闭的州)。 我尝试了这个解
我有一个 Asp.net Gridview,其中最后一列是我的总数,第 2-x 列是我的数字。 我想显示一个显示百分比的条形图 使用找到的示例 Displaying percentage bar wi
我已经添加了控件 if (e.Row.RowType == DataControlRowType.DataRow) { CheckBox chk = new Check
我在同一个页面中得到了两个gridview,它们基本上显示了相同类型的数据(不同的数量、相同的结构、相同的设计……)。 RowDataBound 里面有很多条件都是一样的(99%),所以我想减少代码。
我的网页上有一个 GridView,其数据源是一个在运行时填充的数据表。 GridView 的 AllowSorting 属性为 True。我已经成功地为此 GridView 实现了手动排序。 但我必
我在代码隐藏中创建了一个 gridview(因为它没有实际出现在页面上)。我想知道如何调用它的 rowdatabound 事件 - 因为数据已绑定(bind)到它。正好有一个Gv.RowDataBou
问题 我有一个绑定(bind)到项目表的 Gridview,其中一个属性为 clientid 和其他属性。现在我只想显示 clientid 等于给定 id 的特定行。 我有什么 Change Grid
ASP.net: ... ... C# 代码(在 RowDataDound 中用于 GridView): if (!string.IsNullOrEmpty(e.Row.Cells[4].Text)
触发 RowDataBound 事件,我的问题是如何提取 GridviewRowEventArgs e 的 DataKey? 我有一个 Publications 表,令人惊讶的是,键是 Publica
我正在处理一个 Web Forms 项目。这是一个旧的,这次添加了很多抽象。在我的一个页面上,我有一个带分页的 gridview。我正在尝试通过检查当用户转到下一个页面时当前 gridview 页面上
我的 GridView 中的 TemplateField 是这样创建的: ' ID="HiddenFieldGutscheinartID"/>
我是一名优秀的程序员,十分优秀!