简体   繁体   English

在子网格视图上单击“编辑”时,如何从父网格视图的下拉列表中获取价值?

[英]How to get value in drop down-list from parent Grid-view when Click Edit on child grid-view?

I have nested grid-view. 我有嵌套的网格视图。 In Parent grid View when I Click to Expand the gridview the child gridview shows the related data. 在父网格视图中,当我单击以展开网格视图时,子网格视图将显示相关数据。 But when I click to Edit Child grid view The values go to textbox outside the gridview but not in dropdown list. 但是,当我单击“编辑子网格”视图时,这些值将转到网格视图外部的文本框,但不在下拉列表中。

I have tried 我努力了

 protected void gvSub_RowEditing(object sender, GridViewEditEventArgs e)
{
    GridView gvSub = sender as GridView;
    GridViewRow row = gvSub.Rows[e.NewEditIndex];

    Int32 a = Convert.ToInt32(gvSub.DataKeys[e.NewEditIndex][0]);
    TextBox1.Text = ((Label)row.FindControl("lblName")).Text;
    TextBox2.Text = ((Label)row.FindControl("lblPrice")).Text;
    TextBox3.Text = ((Label)row.FindControl("qty")).Text;

    String Cate = ((Label)gvSub.Parent.FindControl("lblCtName")).Text;
    DropDownList1.Items.FindByValue(Cate.ToString()).Selected = true;  

    btnSub.Text = "Update";
    e.Cancel = true;
}

Parent Gridview Value fetched in Cate but not getting in dropdownlist 父Gridview值在Cate中获取,但未在下拉列表中获取

“ DropDownList1.Items.FindByValue”更改为“ DropDownList1.Items.Add”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法使用DataPager从Rad Grid-View获取所有行 - Cannot get all rows from Rad Grid-View with DataPager 如何使用资源文件在运行时从网格视图插入和编辑 - How to Insert and edit from the grid-view on run time using resource file 单击按钮后,如何使用复选框工具从网格视图隐藏列? - How can I hide columns from a grid-view using a check-box tool on click of a button? 将值从模态弹出式扩展器内部的Grid-View传递到父窗体的文本框 - Passing values from Grid-View inside Modal popup Extender to the text box of parent form 如何查看在数据网格视图中是否存在在文本框中键入的值? - How to look if a value typed in a text box exists in a data grid-view? 如何获取网格视图中的超链接文本并将其发送到另一页 - How to get text of hyperlink which is in grid-view and send that text to another page 如何计算网格视图中的值的按行求和并在网格视图中显示? - how to calculate row-wise sum of values in grid-view and display it in grid view? 按列名称显示/隐藏网格视图列 - show/hide grid-view column by column name C# ASP.NET 在网格视图中添加“删除按钮”到列表 - C# ASP.NET Add "remove button" to List in grid-view 如何在c#asp.net中的多个XML文件中以网格视图或列表视图显示数据 - how can display data in grid-view or listview from multi XML files in c# asp.net
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM