C# .NET - How to get select index change event of drop down list box that is within a grid view ctrl

Asked By prvn kumar on 14-Jun-12 01:34 AM
in my proj i am using  drop down list box placed within grid view control .. how to get select index change event .. please provide a solution for me
Chintan Vaghela replied to prvn kumar on 14-Jun-12 01:38 AM

Hi Frndz,

 

Functionality: Dropdown change event inside GridView

 

 

Added as following way

 

Full Logic:

 

<asp:TemplateField>

          <ItemTemplate>

            <asp:DropDownList ID="ddl" runat="server" OnSelectedIndexChanged="ddlDropwDownlist_SelectedIndexChanged" AutoPostBack="true">

              <asp:ListItem Text="first" Value="first"></asp:ListItem>

              <asp:ListItem Text="second" Value="second"></asp:ListItem>

              <asp:ListItem Text="third" Value="third"></asp:ListItem>

            </asp:DropDownList>

          </ItemTemplate>

        </asp:TemplateField>

 

 

protected void ddlDropwDownlist_SelectedIndexChanged(object sender, EventArgs e)

    {

 

      DropDownList ddl = (DropDownList)sender;

      string a = ddl.SelectedItem.Text;///Gridview selected row dropdown value

    }

 

 

Hope this helpful!

Thanks

 

 

 

TSN ... replied to prvn kumar on 14-Jun-12 01:46 AM

HI…

 

You can do in the below manner just assign the event for the drop down list

<ItemTemplate>

<asp:DropDownListID="DropDownList1"runat="server"AutoPostBack="True"

onselectedindexchanged="DropDownList1_SelectedIndexChanged1"Width="100px"></ItemTemplate>

 

Your Code

protected void DropDownList1_SelectedIndexChanged(object sender,EventArgs e)

{

String selectedValue= DropDownList1.SelectedValue.ToString();

}

prvn kumar replied to Chintan Vaghela on 14-Jun-12 02:10 AM
yes.. It worked.... Thanks.
prvn kumar replied to TSN ... on 14-Jun-12 02:10 AM
It worked.. Thanks
Chintan Vaghela replied to prvn kumar on 14-Jun-12 03:34 AM
welcome :)
TSN ... replied to prvn kumar on 14-Jun-12 09:03 AM
welcome