Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 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
 
Old September 3rd, 2005, 04:22 AM
Authorized User
 
Join Date: Feb 2005
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dependent DropDown In DataGrid

Dear Pals ,


    I am facing a problem in datagrid(ASP.NET with VB.net) . I am showing Dependent dropDownLists in datagrid (2 DropDown) as a template column. But I am not being able to fetch the value of first dropdown list on postback of the dropdownlist1 into a variable.

Please Guide me .


Thanks



Cheers :
K K Singh.
+91-9810481159

Why to be GOOD when U have the ability to be GREAT
__________________
Cheers :
K K Singh.
+91-9810481159

Why to be GOOD when U have the ability to be GREAT
 
Old September 4th, 2005, 11:20 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

You have to create an event handler for your dropdown list then access the value in there:

Protected Sub <your dropdownlist>_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
        ''This sub was created by me manually .. since the ddl is not accessable from the page.
        'Then add this: OnSelectedIndexChanged="<your dropdownlist>_SelectedIndexChanged"
        'To the HTML of the ddl in the DG template column.

        Dim <ddlName>As DropDownList = CType(sender, DropDownList)
        some value = ddlEmployee.SelectedValue
 
Old January 27th, 2007, 05:34 PM
Registered User
 
Join Date: Jan 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Mr Singh...

I am facing a similar problem in my asp.net proj and could not find a definite solution yet.

If you had a solution for dependent dropdowns in datagrid, would appreciate if you could email the same to me at [email protected].

Thanx in advance..

Tushar
 
Old January 29th, 2007, 03:13 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi

You can simply add an event on dropdown's change event and fetch the value, e.g. as below:

Event Code on .cs file
protected void ddl_change(object sender, System.EventArgs e)
        {
            DropDownList dList = (DropDownList) sender;
            string ddlText = (dList.Items[dList.SelectedIndex].Text);
        }

Your dropdown in datagrid looks as below:<asp:TemplateColumn>
                                        <ItemTemplate>
                                            <asp:DropDownList OnSelectedIndexChanged="ddl_change" Runat="server" ID="ddl" AutoPostBack="True">
                                                <asp:ListItem Selected="True">-Select-</asp:ListItem>
                                                <asp:ListItem>First</asp:ListItem>
                                                <asp:ListItem>Second</asp:ListItem>
                                            </asp:DropDownList>
                                        </ItemTemplate>
                                    </asp:TemplateColumn>

Regards
Mike

Fortune favours the brave, so don't regret on missed oppurtunities.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Dependent Dropdown php/mysql/java alexscan Pro PHP 0 December 30th, 2007 09:34 PM
DropDown in DataGrid kiranpanjala Classic ASP Databases 0 January 24th, 2005 10:54 AM
Problem with DataGrid, dependent DDL's john_king General .NET 6 June 30th, 2004 11:15 PM
dependent dropdown lists vivshah VS.NET 2002/2003 1 March 29th, 2004 05:25 PM





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