Write below code in webservice file:
[WebMethod]
public CascadingDropDownNameValue[] fillProducts(string knownCategoryValues, string category)
{
int PrincipalId;
System.Collections.Specialized.StringDictionary PrincipalList = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
PrincipalId = Convert.ToInt32(PrincipalList["ddlPrincipal"]);
objQuotation = new clsQuotation();
objQuotationBO = new clsQuotationBO();
objQuotationBO.I32PrincipalId = Convert.ToInt32(PrincipalId);
objQuotationBO.I32ProductStatus = 1;
DataTable dt = objQuotation.ProductListing(objQuotationBO);
List<CascadingDropDownNameValue> ProductList = new List<CascadingDropDownNameValue>();
if (dt != null)
{
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
ProductList.Add(new CascadingDropDownNameValue(dt.Rows[i]["ProductName"].ToString(), dt.Rows[i]["ProductId"].ToString() + "~" + dt.Rows[i]["Price"].ToString() + "~" + dt.Rows[i]["ProductDescription"].ToString()));
}
}
}
return ProductList.ToArray();
}
[WebMethod]
public CascadingDropDownNameValue[] fillPrincipals()
{
objQuotation = new clsQuotation();
DataTable dt = objQuotation.PrincipalListing();
List<CascadingDropDownNameValue> PrincipalList = new List<CascadingDropDownNameValue>();
if (dt != null)
{
if (dt.Rows.Count > 0)
{
DataView v = dt.DefaultView;
v.RowFilter = "IsDeleted=0";
dt = v.ToTable();
for (int i = 0; i < dt.Rows.Count; i++)
{
PrincipalList.Add(new CascadingDropDownNameValue(dt.Rows[i]["PrincipalName"].ToString(), dt.Rows[i]["PrincipalId"].ToString()));
}
}
}
return PrincipalList.ToArray(); ;
}
////////////////////////// aspx file code
<td style="vertical-align: top">
<asp:DropDownList ID="ddlPrincipal" runat="server" CssClass="drop-down" Style="width: 185px">
</asp:DropDownList>
<asp:CascadingDropDown ID="cddlPrincipal" runat="server" TargetControlID="ddlPrincipal"
Category="ddlPrincipal" PromptText="- Please Select -" ServicePath="~/GetMasterData.asmx"
ServiceMethod="fillPrincipals" LoadingText="Please wait">
</asp:CascadingDropDown><%--SelectedValue='<%# Eval("PrincipalId") %>'--%>
</td>
<td style="vertical-align: top" >
<asp:DropDownList ID="ddlProducts" runat="server" CssClass="drop-down" Style="width: 165px">
</asp:DropDownList>
<asp:CascadingDropDown ID="cddlProducts" runat="server" TargetControlID="ddlProducts" ParentControlID="ddlPrincipal"
Category="ddlProducts" PromptText="- Please Select -" ServicePath="~/GetMasterData.asmx"
ServiceMethod="fillProducts" UseContextKey="true" ></asp:CascadingDropDown>
</td>
[WebMethod]
public CascadingDropDownNameValue[] fillProducts(string knownCategoryValues, string category)
{
int PrincipalId;
System.Collections.Specialized.StringDictionary PrincipalList = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
PrincipalId = Convert.ToInt32(PrincipalList["ddlPrincipal"]);
objQuotation = new clsQuotation();
objQuotationBO = new clsQuotationBO();
objQuotationBO.I32PrincipalId = Convert.ToInt32(PrincipalId);
objQuotationBO.I32ProductStatus = 1;
DataTable dt = objQuotation.ProductListing(objQuotationBO);
List<CascadingDropDownNameValue> ProductList = new List<CascadingDropDownNameValue>();
if (dt != null)
{
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
ProductList.Add(new CascadingDropDownNameValue(dt.Rows[i]["ProductName"].ToString(), dt.Rows[i]["ProductId"].ToString() + "~" + dt.Rows[i]["Price"].ToString() + "~" + dt.Rows[i]["ProductDescription"].ToString()));
}
}
}
return ProductList.ToArray();
}
[WebMethod]
public CascadingDropDownNameValue[] fillPrincipals()
{
objQuotation = new clsQuotation();
DataTable dt = objQuotation.PrincipalListing();
List<CascadingDropDownNameValue> PrincipalList = new List<CascadingDropDownNameValue>();
if (dt != null)
{
if (dt.Rows.Count > 0)
{
DataView v = dt.DefaultView;
v.RowFilter = "IsDeleted=0";
dt = v.ToTable();
for (int i = 0; i < dt.Rows.Count; i++)
{
PrincipalList.Add(new CascadingDropDownNameValue(dt.Rows[i]["PrincipalName"].ToString(), dt.Rows[i]["PrincipalId"].ToString()));
}
}
}
return PrincipalList.ToArray(); ;
}
////////////////////////// aspx file code
<td style="vertical-align: top">
<asp:DropDownList ID="ddlPrincipal" runat="server" CssClass="drop-down" Style="width: 185px">
</asp:DropDownList>
<asp:CascadingDropDown ID="cddlPrincipal" runat="server" TargetControlID="ddlPrincipal"
Category="ddlPrincipal" PromptText="- Please Select -" ServicePath="~/GetMasterData.asmx"
ServiceMethod="fillPrincipals" LoadingText="Please wait">
</asp:CascadingDropDown><%--SelectedValue='<%# Eval("PrincipalId") %>'--%>
</td>
<td style="vertical-align: top" >
<asp:DropDownList ID="ddlProducts" runat="server" CssClass="drop-down" Style="width: 165px">
</asp:DropDownList>
<asp:CascadingDropDown ID="cddlProducts" runat="server" TargetControlID="ddlProducts" ParentControlID="ddlPrincipal"
Category="ddlProducts" PromptText="- Please Select -" ServicePath="~/GetMasterData.asmx"
ServiceMethod="fillProducts" UseContextKey="true" ></asp:CascadingDropDown>
</td>
No comments:
Post a Comment