Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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 February 3rd, 2005, 05:44 PM
Authorized User
 
Join Date: Dec 2003
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default Datagrid footer template dropdown list problem

Hi,
I have a datagrid with footer contains two dropdown lists. When first dropdown list selected, second dropdown should populate from the database. I have the problem with second dropdown list.It's not populating the data.I tried to debug the code.It found the 'Footer template' control and also the database query is working fine.
Here is the code. Could you please help.

Regards..

<asp:datagrid id="dgCust" runat="server"
AutoGenerateColumns="False"
OnItemCommand="dg_Insert"
ShowFooter="True"
<Columns>
---
<FooterTemplate>
<asp:DropDownList runat="server" id="lstMaster"
DataValueField="ID" DataTextField="cust_Name"
DataSource='<%# GetList() %>'
AutoPostBack="True"
OnSelectedIndexChanged="PopulateSecondList" />
</FooterTemplate>
</asp:TemplateColumn>

<FooterTemplate>
<asp:DropDownList runat="server" id="lstDetails"
DataValueField="ID" DataTextField="Location"
DataSource='<%# GetSecondList(-1) %>' />
</FooterTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>

Code behind file
-----------------------
Sub PopulateSecondList(sender as Object, e as EventArgs)

Dim Master as DropDownList = sender

Dim dgDetail as DataGridItem = Master.Parent.Parent
Dim test as DropDownList = dgDetail.FindControl("lstDetails")

Dim cID as Integer = Master.SelectedItem.Value

test .DataSource = GetSecondList(cID)
test .DataBind()
End Sub
---------------
Function GetSecondList(cID as Integer) as DataTable
Dim sql as String
sql = "SELECT id, location, description from test where id =" & cID
Dim myDataAdapter as SqlDataAdapter = New SqlDataAdapter(sql, myConnection)

myDataAdapter.Fill(myDataSet, "SAT")

Return myDataSet.Tables("SAT")
End Function







Similar Threads
Thread Thread Starter Forum Replies Last Post
can we bind datagrid and dropdown list rakeshgv SQL Server 2000 0 August 21st, 2006 02:13 AM
Dropdown list in a datagrid maddy137 ASP.NET 1.0 and 1.1 Professional 0 May 19th, 2006 02:05 PM
populating a dropdown list within a datagrid in C# akshay144 General .NET 0 May 12th, 2006 04:44 AM
problem with dropdown list in datagrid marty_nguyen Classic ASP Databases 1 May 22nd, 2005 06:16 PM





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