Objectdatasource select parameters in n-tier RRS feed

  • Question

  • User-1009338840 posted
    I'm writing an asp.net application with gridview using objectdatasource. There are number if text box fields on the form for the user to search on.
    I've setup the objectdatasource with a BLL and select parameters. So it passes 10 parameters, but then I need to pass those 10 parameters to the DAL.

    Is there any versatile way to do this rather pass all the variables?what is the Best Practise? Perhaps into an object class?
    Thursday, May 15, 2014 5:58 AM


  • User697462465 posted

    Hi alphabeatsco,

    I suggest you create a class to store these parameters, like this:

    public class ParameterClass{
        public string para1{get;set;}
        public string para2{get;set;}
        public string para3{get;set;}
        public string para4{get;set;}
        public string para5{get;set;}
        public string para6{get;set;}

    And then store your parameters to the class instance, like this:

    ParameterClass instance = new ParameterClass();
    instance.para1 = TxtPara1.Text;
    instance.para2 = TxtPara2.Text;
    instance.para3 = TxtPara3.Text;
    instance.para4 = TxtPara4.Text;
    instance.para5 = TxtPara5.Text;
    var result = GetResult(instance);

    Hope it helps.

    Best Regards,
    Terry Guo

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 15, 2014 10:39 PM