.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

Cascading dropdown problem

Posted By: Subha     Posted Date: July 18, 2010    Points:2   Category :ASP.Net
I have use the below coding to bind the data into the dropdownlist with in gridview.The data bind only in cascadingdropdown1 not in cascadingdropdown2.when i click the cascadingdropdown1 it will simply generate method error 500.
source:
<asp:GridView runat="server" ID="gdViewStaff" DataKeyNames ="Allocate_id" CssClass ="MyGridView">
<HeaderStyle CssClass="MyGridView_Header" />
<PagerStyle CssClass="MyGridView_PagerStyle" />

<Columns >

<asp:TemplateField HeaderText ="Department" visible="false" >
<EditItemTemplate >
<asp:DropDownList runat="server" ID="ddleditdept" >
</asp:DropDownList>
<%-- <cc1:CascadingDropDown ID="CascadingDropDown1" runat="server"
TargetControlID ="ddleditdept"
PromptText="-Select Department-"
LoadingText="Loading Department.."
ServicePath="Cascading.asmx"
ServiceMethod="Fill_Dept">
</cc1:CascadingDropDown>--%>
<cc1:CascadingDropDown ID="CascadingDropDown1" runat="server" TargetControlID ="ddleditdept"
Category ="Department_Name" ServiceMethod="Fill_Dept" ServicePath="Cascading.asmx">
</cc1:CascadingDropDown>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="StaffName" Visible ="false">
<EditItemTemplate>
<asp:DropDownList runat="server" ID="ddleditstaff">

</asp:DropDownList>
<cc1:CascadingDropDown ID="CascadingDropDown2" runat="server"
TargetControlID ="ddleditstaff"
Category ="name" ContextKey ="ddleditdept" UseContextKey ="true" ParentControlID ="ddleditdept"
ServicePath="Cascading.asmx"
ServiceMethod="Fill_Staff">
</cc1:CascadingDropDown>
</EditItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText ="Staff_ID" Visible ="false" >
<EditItemTemplate >
<asp:TextBox ID="staffid1" runat="server"></asp:TextBox>
<asp:Label ID="staffid" runat="server" Visible ="false" Text='<%#Bind("Staff_ID") %>' ></asp:Label>
</EditItemTemplate>
</asp:TemplateField>


<asp:TemplateField HeaderText ="Staff_Name" Visible ="false" >
<EditItemTemplate >
<asp:TextBox ID="staffname1" runat="server"></asp:TextBox>
<asp:Label ID="staffname" runat="server" Visible ="false" Text='<%#Bind("Staff_Name") %>' ></asp:Label>
</EditItemTemplate>
</asp:TemplateField>




<asp:TemplateField HeaderText ="Subj" Visible ="false" >
<EditItemTemplate >
<asp:TextBox ID="subj1" runat="server"></asp:TextBox>
<asp:Label ID="subj" runat="server" Visible ="false" Text='<%#Bind("Subj") %>' ></asp:Label>
</EditItemTemplate>
</asp:TemplateField>



<asp:TemplateField HeaderText ="Allocate" Visible ="false" >
<EditItemTemplate >
<asp:TextBox ID="Allocate1" runat="server"></asp:TextBox>
<asp:Label ID="Allocate" runat="server" Visible ="false" Text='<%#Bind("Allocate_id") %>' ></asp:Label>
</EditItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText ="Batch" Visible ="false" >
<EditItemTemplate >
<asp:TextBox ID="Batch1" runat="server"></asp:TextBox>
<asp:Label ID="Batch" runat="server" Visible ="false" Text='<%#Bind("Batch") %>' ></asp:Label>
</EditItemTemplate>
</asp:TemplateField>

<asp:CommandField EditText="Edit" UpdateText="Update" HeaderText="Edit" DeleteText="Delete"
CancelText="Cancel"
ShowEditButton="true" ValidationGroup="valgrid" ShowDeleteButton="true" >
<ControlStyle />
</asp:CommandField>
</Columns>
</asp:GridView>



Webservice code:
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Collections.Generic
Imports System.Configuration
Imports System.Data
Imports System.Data.SqlClient
Imports System.Collections.Specialized
Imports AjaxControlToolkit
Imports System.ComponentModel

' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class WebService
Inherits System.Web.Services.WebService


Dim con As New SqlConnection
Dim cmd As New SqlCommand
Dim dr As SqlDataReader
Dim da As New SqlDataAdapter()
Dim ds As New DataSet

Dim strsql As String
<WebMethod()> Public Function Fill_Dept(ByVal knownCategoryValues As String, ByVal category As String) As CascadingDropDownNameValue()
con.ConnectionString = ConfigurationManager.AppSettings.Item("ConnectionInfo")
con.Open()
cmd = New SqlCommand("select * from Adm_department", con)
Dim da As New SqlDataAdapter()
Dim ds As New DataSet()
da.SelectCommand = cmd
da.Fill(ds, "test")
'Return ds
Dim countryNames As New List(Of CascadingDropDownNameValue)()
For Each dRow As DataRow In ds.Tables(0).Rows
Dim deptID As Integer = dRow("Department_ID").ToString()
Dim deptname As String = dRow("Department_Name").ToString()
countryNames.Add(New CascadingDropDownNameValue(deptname, deptID))
Next

Return countryNames.ToArray()
End Function
<WebMethod()> Public Function Fill_Staff(ByVal knownCategoryValues As String, ByVal category As String, ByVal contextKey As String) As CascadingDropDownNameValue()
Dim kv As StringDictionary = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues)
Dim UpperCatlevelID As String = category

con.Open()
cmd = New SqlCommand("select * from Staffbio where dept=@dept", con)
cmd.Parameters.Add(New SqlParameter("@dept", UpperCatlevelID))
Dim da As New SqlDataAdapter()
Dim ds As New DataSet()
da.SelectCommand = cmd
da.Fill(ds, "test")

Dim countryNames As New List(Of CascadingDropDownNameValue)()
For Each dRow As DataRow In ds.Tables(0).Rows
Dim deptName As String = dRow("name").ToString()
MsgBox(deptName)
Dim deptId As String = dRow("dept").ToString()
countryNames.Add(New CascadingDropDownNameValue(deptName, deptId))
Next
Return countryNames.ToArray()
End Function
End Class


How can i resolve the problem.

Responses
Author: BangaruBabuPureti             
Posted Date: July 22, 2010     Points: 5   


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend