繁体   English   中英

DropDownList 索引更改事件中具有 DropDownList 的行中的值

[英]Value from row with DropDownList on DropDownList Index Changed Event

代码:

    <asp:GridView ID="gv_Recruit" AutoGenerateColumns="False" Width="100%"
     runat="server" OnRowCreated="gvStates_RowCreated" 
        OnRowDataBound="gvStates_RowCreated">
  <Columns>
    <asp:BoundField HeaderText="key" DataField="key" />
    <asp:BoundField HeaderText="Name" DataField="Name" />
    <asp:BoundField HeaderText="Quota" DataField="Quota" />
    <asp:BoundField HeaderText="Session" DataField="Sess" >
      <ItemStyle HorizontalAlign="Center" />
      </asp:BoundField>
    <asp:TemplateField HeaderText="">
      <ItemTemplate>
        <asp:DropDownList ID="ddlCities" Width="100%" AutoPostBack="true" runat="server" OnSelectedIndexChanged="ddl_selected">
        </asp:DropDownList>
      </ItemTemplate>
    </asp:TemplateField>
    <asp:BoundField HeaderText="Recruiter" DataField="Recruiter" />
    <asp:BoundField HeaderText="MN Phone" DataField="MN Phone" />
    <asp:BoundField HeaderText="Cell Phone" DataField="Cell Phone" />
  </Columns>
</asp:GridView>

代码背后:

protected void ddl_selected(object sender, EventArgs e)
{
    string _dd_value = ((DropDownList)sender).SelectedValue;
    string trying_to_get = gv_Recruit.Rows[???].Cells[0].Text.ToString(); 
    string also_tried = gv_Recruit.SelectedRow.Cells[0].Text.ToString();
}

基本上我要做的是在下拉列表更改时从第一行获取键值,以便我可以执行更新???

想不通这个。

在此先感谢您的帮助...

尝试

 GridViewRow gRow = (GridViewRow)(sender as Control).Parent.Parent;
 string trying_to_get = string.Empty;
 if (gRow != null) 
 {
    trying_to_get = gRow.Cells[0].Text;
 }

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM