Hi all,
I have a Project due after one week. It is a web service project. I have a Web Form which communicates to the web service and this web service communicates to the database. I have all my SQL statements in the Data Acess Layer to create more secure web service application. The Web service class is also in the Data Access Layer. I need to populates the 4 Dropdown list boxes on the web form from one table. I have Customer table which contains information About CustomerName, CustomerType, Address, City. These 4 colum values should populate the 4 Dropdown lists. And then I need to implement those 4 dropdowns like this. When the user selects a Customername it should display relevant customer information in the GridView. Or when the user selects values from all 4 listboxes it should display all information on GridView as well.
For all the above I have just populated one listbox but I don't know how to populate the other 3 dropdown lists and implement them on the web form.
I have created one method in the Data Access Layer class and one method in the Web Service class and then I instaitiated the web service object in the web form by adding a web reference. It works fine for just populating one dropdown list box but for the whole 4 dropdown list I am unable to populated and Implement them.
Below are the methods and the code for one dropdownlist.
(1)Web Form code:
WebService.Service ws = new WebService.Service();
protected void Page_Load(object sender, EventArgs e)
{
object[] alist;
alist = ws.GetBusinessType(string.Empty);
DropDownList1.DataSource = alist;
DropDownList1.DataBind();
(2) Web Service Method:
[WebMethod]
public ArrayList GetBusinessType(string btype)
{
DAccess ODA = new DAccess(); //Data Access object
ArrayList list = new ArrayList();
list = ODA.GetBusinessType(btype); //Data Access method
return list;
}
(3) Data Access method:
public ArrayList GetBusinessType(string btype)
{
SqlConnection connection = GetConnection;
try
{
ArrayList arrbt = new ArrayList();
StringBuilder sql = new StringBuilder()
.AppendLine("SELECT")
.AppendLine("\tTYPENAME")
.AppendLine("\tFROM")
.AppendLine("\tBUSINESS_TYPE");
SqlParameter paramTYPENAME = new SqlParameter("TYPENAME", SqlDbType.NVarChar);
paramTYPENAME.Value = btype;
connection.Open();
SqlDataReader reader = ExecuteQuery(connection, sql.ToString(), paramTYPENAME);
while (reader.Read())
{
string result = reader["TYPENAME"].ToString();
arrbt.Add(result);
}
return arrbt;
}
catch (Exception ex)
{
return null;
//do some log here Call a class that logs the errors
}
finally
{
connection.Close();
}
All the above code works fine for just populating the one dropdown list but not implementing. I just want the implementation something like....When the user select one dropdown or all of them then it should display the result in the gridview. I have not shown the aspx code here but the main thing is the code above. Can any one help me to implement this
I really appreciate your help. Looking forward to your reply.
Thanks
Koonda