开发者

Value from row with DropDownList on DropDownList Index Changed Event

开发者 https://www.devze.com 2023-03-09 02:58 出处:网络
Code: <asp:GridView ID=\"gv_Recruit\" AutoGenerateColumns=\"False\" Width=\"100%\" runat=\"server\" OnRowCreated=\"gvStates_RowCreated\"

Code:

    <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:Boun开发者_运维问答dField>
    <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>

Code Behind:

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();
}

Basically what I'm trying to do is get the key value from the first row when the drop down is changed so I can perform an update ???

Can't figure this out.

Thanks in advance for the help...


Try

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

精彩评论

暂无评论...
验证码 换一张
取 消