2016-12-03 7 views
0

GridViewにDropDownListがあり、GridView内のDropDownListの選択値をGridView内にバインドして、 # C asp.netでクエリ文字列にあなたがでのAddHandlerのいずれかを使用して、いずれかのマークアップでは、それぞれの子ドロップダウンにSelectedIndexChangedイベントにメソッドを付けることができ、私が案内してDropDownListの ののSelectedIndexChangedのコードscreenshot of GridViewDropDownListをGridViewにドロップして、ドロップダウンの選択した値をasp.netのGridView内のTextBoxにバインドするC#

答えて

0

する助けてくださいグリッドビューのRowDataBoundイベント

<asp:GridView ID="gv1" runat="server"> 
     <Columns> 
      <asp:TemplateField> 
       <ItemTemplate> 
        <asp:DropDownList ID="ddl" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlSelectedIndexChanged"> 
         <asp:ListItem Value="1"></asp:ListItem> 
         <asp:ListItem Value="2"></asp:ListItem> 
         <asp:ListItem Value="3"></asp:ListItem> 
        </asp:DropDownList> 
       </ItemTemplate> 
      </asp:TemplateField> 
     </Columns> 
    </asp:GridView> 

    <asp:TextBox ID="txt1" runat="server" /> 
    <asp:Button ID="btn1" runat="server" Text="redirect" /> 
選択した項目が
protected void ddlSelectedIndexChanged(object sender, System.EventArgs e) 
{ 
    DropDownList ddl = (DropDownList)sender; 
    txt1.Text = ddl.SelectedValue; 
} 

を変更し、ボタンを

private void btn1_Click(object sender, EventArgs e) 
{ 
    Response.Redirect("mypage.aspx?q=" + txt1.Text); 
} 

をクリックすると、この値を使用するか、ドロップダウンにatttached jqueryのonChangeイベントを使用している

保存したい場所に値(非表示またはテキストボックス) ?

$('select').on('change', function() { 
    alert(this.value); 
}) 
+0

ありがとうございました –

関連する問題