Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 17th, 2009, 07:01 AM
Authorized User
Points: 91, Level: 1
Points: 91, Level: 1 Points: 91, Level: 1 Points: 91, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2009
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Post DropDownList SelectedIndexChanged in gridview

hi everbody....

I have taken 3 dropdownlists in gridview when i select the value in first dropdownlist then accourding to that value i should bind 2 and 3 dropdownlists.
my first dropdownlist SelectedIndexChanged event is not firing...

Code:
 
    protected void grid1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            string s2 = "select subDivisionName from Tbh_SubDivsionMaster";
            SqlDataAdapter ada = new SqlDataAdapter(s2, con);
            DataSet ds = new DataSet();
            ada.Fill(ds);
            DropDownList ddl1 = (DropDownList)e.Row.FindControl("ddl1");
            ddl1.DataSource = ds;
            ddl1.DataTextField = "subDivisionName";
            ddl1.DataBind();
         }
    }
    protected void ddl1_SelectedIndexChanged1(object sender,EventArgs e)
    {
        DropDownList d1=new DropDownList();
        DropDownList d2=new DropDownList();
        DropDownList d3=new DropDownList();
        foreach(GridViewRow row in grid1.Rows)
        {
            d1=(DropDownList)row.FindControl("ddl1");
            d2=(DropDownList)row.FindControl("div");
            d3=(DropDownList)row.FindControl("cir");
            if (d1.SelectedValue.ToString() == "CD I UDR")
            {
                d2.Visible = false;
                d3.Visible = false;
            }
            else
            {
                d2.Visible = true;
                d2.Visible = true;
            }
        }
    }
HTML Code:
 <asp:GridView ID="grid1" runat="server" OnRowDataBound="grid1_RowDataBound"  AutoGenerateColumns="False" BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px" CellPadding="2" ForeColor="Black" GridLines="None"     >
                               <Columns>
                                 <asp:TemplateField>
                                      
                                      <ItemTemplate>
                                            <asp:DropDownList ID="ddl1" runat="server" DataTextField="subDivisionName" OnSelectedIndexChanged="ddl1_SelectedIndexChanged1" AutoPostBack="true" >
                                            
                                            </asp:DropDownList>
                                        </ItemTemplate>
                                 </asp:TemplateField>
                                 <asp:TemplateField>
                                      
                                      <ItemTemplate>
                                            <asp:DropDownList ID="div" runat="server" DataTextField="DivisionName"   ></asp:DropDownList>
                                        </ItemTemplate>
                                 </asp:TemplateField>
                                 <asp:TemplateField>
                                    
                                      <ItemTemplate>
                                            <asp:DropDownList ID="cir" runat="server" DataTextField="Circle" ></asp:DropDownList>
                                        </ItemTemplate>
                                 </asp:TemplateField>
                                 <asp:TemplateField>
                                     
                                      <ItemTemplate>
                                            <asp:Label ID="empname" runat="server" Text='<%#Bind("EmployeeName")%>'></asp:Label>
                                        </ItemTemplate>
                                 </asp:TemplateField>
                                   
                               </Columns>
                              
                          </asp:GridView>


Similar Threads
Thread Thread Starter Forum Replies Last Post
dropdownlist on selectedindexchanged RoniR ASP.NET 1.x and 2.0 Application Design 4 April 6th, 2012 04:50 PM
DropDownList SelectedIndexChanged Event does not davej ASP.NET 2.0 Basics 3 October 12th, 2007 10:20 AM
Problem with Dropdownlist.SelectedIndexChanged haydar BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 0 July 20th, 2007 10:26 AM
GridView SelectedIndexChanged event bnorg ASP.NET 2.0 Professional 1 July 7th, 2007 01:14 AM
DropDownList SelectedIndexChanged problem p_heidi ASP.NET 1.0 and 1.1 Basics 3 April 27th, 2006 10:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.