Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

C# shopping basket, trying to remove an item...

  • 07-04-2009 1:02pm
    #1
    Closed Accounts Posts: 7,097 ✭✭✭


    Hi all,

    I've built a shopping basket/cart that works great, it works by adding a record to my database on a Button_Click event, and I display the contents of the records in my DB (the contents of the shopping cart), by using the solution below. What it does is append a new record to a string, using a while loop, each time something is added to the basket, which works great.

    The only problem I have now is if someone wants to remove something from the cart, I've been pulling out my hair trying to come up with a solution for this that is consistent with the approach below. It should be easy as I have a unique key for this table so every record has a unique ID that can be identified/deleted but where I'm stuck is I can't work out how to put a button or a hyperlink inside my while loop and bind the behaviour of this event handler to the unique ID in my DB??? Is it possible to put a button or a hyperlink (that does something besides bring you to another page), inside a label and also inside a while loop???

    What I need is if I have 3 items in my cart, I need 3 buttons or something else like a hyperlink beside each item, to remove it from the cart or more accurately to remove it from my DB. The while loop just runs through the table when the purchase button is clicked and picks out any records that share the same SessionID.

    SqlDataReader DataReader;
    DataReader = cmdy.ExecuteReader();

    if (DataReader.HasRows)
    {
    Label13.Text = "";

    while (DataReader.Read())
    {
    object obj1 = new object();
    obj1 = string.Format(DataReader["eq_type"].ToString());

    object obj2 = new object();
    obj2 = string.Format(DataReader["eq_make"].ToString());

    object obj3 = new object();
    obj3 = string.Format(DataReader["eq_model"].ToString());

    object obj4 = new object();
    obj4 = string.Format(DataReader["Component_Manufacturer"].ToString());

    object obj5 = new object();
    obj5 = string.Format(DataReader["Product_Description"].ToString());

    object obj6 = new object();
    obj6 = string.Format(DataReader["Retail_Price"].ToString());

    object obj7 = new object();
    obj7 = string.Format(DataReader["Item_ID"].ToString());



    string newstring = string.Concat(obj1," " + obj2, " " + obj3, "<br>" + obj4, " " + obj5, "<br> <p1>Retail Price: € " + obj6);
    Label13.Text += string.Format(newstring.ToString() + "<br><br>");

    Label16.Text = string.Format("Shopping Cart: € {0}", Convert.ToString(cmdu.ExecuteScalar()));

    Label8.Text = string.Format("Shipping Cost: € {0:F2}", Convert.ToDecimal(Delivery));

    //string FullTotal = Convert.ToString(cmdu.ExecuteScalar()) + Convert.ToString(cmdL.ExecuteScalar());
    //Label9.Text = string.Format(FullTotal);

    decimal Cart = Convert.ToDecimal(cmdu.ExecuteScalar());
    decimal Carry = Convert.ToDecimal(Delivery);

    decimal Cart_Total = Cart + Carry;
    //Label9.Text = Cart_Total.ToString();
    Label9.Text = string.Format("Total Invoice: € {0:F2}", Cart_Total);

    Any help hugely appreciated!


«13456

Comments

  • Registered Users, Registered Users 2 Posts: 2,629 ✭✭✭LowOdour


    Have to say that im not really gone on the idea of storing records in a database that may not get used. It means you could be hitting the database with 100 different products that may never get purchased.
    But thats not your question!

    inside the while loop you could generate some html, which will spit out the code for a html button. You could add the id of the product while generating the html and also an onclick call which would pass the id as a parameter. Have a javascript call that when the button is clicked, it shows a dialog box informing of the delete. Hit the ok button, it calls a delete page that deletes the record and returns you to the page with the other products.
    string = "< input type=\"button\" id = \""+GetIDFromDBHere+"\" onclick ="\"+CallJavaScriptHereWithID+"\" />";

    Couple of things...this can definately be done simpler than ive explained it, but its a start for you. You may not need the extra delete form, its only if you want to inform the user.


  • Closed Accounts Posts: 7,097 ✭✭✭Darragh29


    LowOdour wrote: »
    Have to say that im not really gone on the idea of storing records in a database that may not get used. It means you could be hitting the database with 100 different products that may never get purchased.
    But thats not your question!

    inside the while loop you could generate some html, which will spit out the code for a html button. You could add the id of the product while generating the html and also an onclick call which would pass the id as a parameter. Have a javascript call that when the button is clicked, it shows a dialog box informing of the delete. Hit the ok button, it calls a delete page that deletes the record and returns you to the page with the other products.
    string = "< input type=\"button\" id = \""+GetIDFromDBHere+"\" onclick ="\"+CallJavaScriptHereWithID+"\" />";

    Couple of things...this can definately be done simpler than ive explained it, but its a start for you. You may not need the extra delete form, its only if you want to inform the user.

    Hi LowOdour,

    I don't think your solution can be used for my problem because the while loop is in a codebehind C# page, separate from the HTML code...


  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭John_Mc


    Darragh29 wrote: »
    Hi LowOdour,

    I don't think your solution can be used for my problem because the while loop is in a codebehind C# page, separate from the HTML code...

    Put a runat=server in the <input> tag and you can access the clientID property of the control in the codebehind.

    < input type=\"button\" id = \""+GetIDFromDBHere+"\" onclick ="\"+CallJavaScriptHereWithID+"\" runat="server" />

    In the while loop then you could set the onclick property of the input type:

    GetIDFromDBHere.onclick="functionName('" + GetIDFromDBHere.ClientID +"');";


  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭John_Mc


    Another alternative is to add an asp.net button in the while loop. You could set it's ID, CommandName and CommandArgument to whatever type of button it is.

    Should be a simple enough solution. For me at least, it'd be easier than using javascript and a seperate form as suggested above


  • Closed Accounts Posts: 7,097 ✭✭✭Darragh29


    Ok, I've decided to use an asp.net LinkButton to get me over this last hurdle...

    Right now, I have my LinkButton in my aspx page, but where I'm stuck is actually getting my while loop to create a new instance of the button for each record in my DB. Can I create an instance of a LinkButton from my codebehind page??? If I can, I think I can crack this...


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭John_Mc


    Darragh29 wrote: »
    Ok, I've decided to use an asp.net LinkButton to get me over this last hurdle...

    Right now, I have my LinkButton in my aspx page, but where I'm stuck is actually getting my while loop to create a new instance of the button for each record in my DB. Can I create an instance of a LinkButton from my codebehind page??? If I can, I think I can crack this...

    You can create pretty much add anything in the code behind :)

    I'm writing this without a compiler so you'll probably need to correct the case in some places:
    LinkButton lb = new LinkButton();
    lb.id="delete_cmd" + n; //n is your index for looping or just a counter
    lb.Text="Delete";
    lb.CommandName="Delete";
    lb.CommandArgument=nRowID;
    lb.OnClick="EventHandlerName";
    //lb.OnClientClick="";
    //Set any other properties here
    
    //Then add to a container such as a placeholder or panel
    CartPanel.Controls.Add(lb);
    

    I know that you're new to this so I'll save you some future headache and advise you to lookup the .net page life cycle. You'll have all sorts of problems with dynamically added controls if you dont fully grasp it.


  • Closed Accounts Posts: 7,097 ✭✭✭Darragh29


    John_Mc wrote: »
    You can create pretty much add anything in the code behind :)

    I'm writing this without a compiler so you'll probably need to correct the case in some places:
    LinkButton lb = new LinkButton();
    lb.id="delete_cmd" + n; //n is your index for looping or just a counter
    lb.Text="Delete";
    lb.CommandName="Delete";
    lb.CommandArgument=nRowID;
    lb.OnClick="EventHandlerName";
    //lb.OnClientClick="";
    //Set any other properties here
    
    //Then add to a container such as a placeholder or panel
    CartPanel.Controls.Add(lb);
    

    I know that you're new to this so I'll save you some future headache and advise you to lookup the .net page life cycle. You'll have all sorts of problems with dynamically added controls if you dont fully grasp it.

    Ya see here is my problem, I have to get the LinkButton into my Label that is appended above, or at least I think I do if I want to stick with my approach above... So I can't use a placeholder then I think??? I dunno!


  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭John_Mc


    Darragh29 wrote: »
    Ya see here is my problem, I have to get the LinkButton into my Label that is appended above, or at least I think I do if I want to stick with my approach above... So I can't use a placeholder then I think??? I dunno!

    Sorry, you've lost me here. Why do you need to insert into a Label?


  • Closed Accounts Posts: 7,097 ✭✭✭Darragh29


    John_Mc wrote: »
    Sorry, you've lost me here. Why do you need to insert into a Label?

    Thanks for sticking with me so far John... This is my problem here, I use an appended string to display the shopping cart contents back to the aspx page, and then I display the value of the appended string in a Label. What I'm trying to do is come up with some way of putting a LinkButton that will delete, into the appended string, that goes into the Label.

    If I can't do this, I think I'll have to go backwards and come up with another way of displaying the shopping cart contents in the aspx page. :confused::confused::confused:


  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭John_Mc


    Darragh29 wrote: »
    Thanks for sticking with me so far John... This is my problem here, I use an appended string to display the shopping cart contents back to the aspx page, and then I display the value of the appended string in a Label. What I'm trying to do is come up with some way of putting a LinkButton that will delete, into the appended string, that goes into the Label.

    If I can't do this, I think I'll have to go backwards and come up with another way of displaying the shopping cart contents in the aspx page. :confused::confused::confused:

    Why cant you use a placeholder or panel instead of the label?

    You can add any control you want to the container without it being constrained to html markup (as would be the case in a label).

    You can still use the Appended string, but populate the container instead of the label.


  • Advertisement
  • Closed Accounts Posts: 7,097 ✭✭✭Darragh29


    John_Mc wrote: »
    Why cant you use a placeholder or panel instead of the label?

    You can add any control you want to the container without it being constrained to html markup (as would be the case in a label).

    You can still use the Appended string, but populate the container instead of the label.

    OK, I'll give it a shot, I'm just nervous changing it because apart from the delete item issue, it works perfectly.... But I'll copy the page and change the new copy and see how I fare out...


  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭John_Mc


    Darragh29 wrote: »
    OK, I'll give it a shot, I'm just nervous changing it because apart from the delete item issue, it works perfectly.... But I'll copy the page and change the new copy and see how I fare out...

    Yeah make a backup of it so you have that to fall back on should thinks go wrong.

    The method I've suggested is relatively easy to implement and will be valuable learning for you. You may encounter problems with Postback but we can cross that bridge when we come to it.

    You'll probably be able to reuse most of your code, except where it sets the label value, instead create a new label with the value and add it to the panel/placeholder.

    Label lb = new Label();
    lb.ID="lblCartRow";
    lb.Text="Blah Blah";
    lb.CssClass="cartLabel";
    //Add to panel.

    panCar.Controls.Add(lb);

    If you're intending on having rows of these labels, then insert a literal control with "<div style="width:100%;">" before and </div> afterwards.

    You will also put your delete button in between these, and any other buttons you may want.


  • Closed Accounts Posts: 7,097 ✭✭✭Darragh29


    OK, I have my container working, I can read a field from my DB and click on my purchase button and it appears in the container. Do I just repeat this process to get the rest of the information that I had appended into my label, to now appear in the container?


  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭John_Mc


    Darragh29 wrote: »
    OK, I have my container working, I can read a field from my DB and click on my purchase button and it appears in the container. Do I just repeat this process to get the rest of the information that I had appended into my label, to now appear in the container?

    The answer to that really depends on what your requirements are...

    So you have the items displaying in the container, and you now want to add a delete button. Is that where you want to go from here?

    You just need to add some more logic to the loop which creates a Button/Linkbutton with command arguments that can be used to identify that record in the delete event handler. If you've added the cart item to the DB as a record, you can set the command arg to the records ID.
    Set the button event handler and finally, add the button to the panel.


  • Closed Accounts Posts: 7,097 ✭✭✭Darragh29


    John_Mc wrote: »
    The answer to that really depends on what your requirements are...

    So you have the items displaying in the container, and you now want to add a delete button. Is that where you want to go from here?

    You just need to add some more logic to the loop which creates a Button/Linkbutton with command arguments that can be used to identify that record in the delete event handler. If you've added the cart item to the DB as a record, you can set the command arg to the records ID.
    Set the button event handler and finally, add the button to the panel.

    I've managed to get the original data into the container and also the LinkButton to delete the record, which is appearing with each iteration of an item in my shopping cart (this was one obstacle that I couldn't overcome until you suggested using the container solution), and I've used:

    LNK.ID = string.Format(DataReader["Project_id"].ToString());

    To assign the ID of each LinkButton, to equal the unique ID for each item in my DB.

    Now I think all I need to do is write some code to go into the DB when each LinkButton is clicked and run an SQL query to delete the row WHERE Project_id = LinkButtonID, of something along those lines...

    This is my last question! On a Button Click, I can use:

    protected void Button1_Click(object sender, EventArgs e)

    {
    To do whatever I want to do...
    }

    But can I do the same with a LinkButton??? Also, what's the story with having an undefined number of LinkButtons, depending on the number of items within my cart???

    Here's my code sofar...

    string newstring = string.Concat(obj1," " + obj2, " " + obj3, "<br>" + obj4, " " + obj5, "<br>Retail Price: € " + obj6,"<BR>");

    Label lb = new Label();
    lb.ID = string.Format(DataReader["Project_id"].ToString());
    lb.Text = newstring.ToString();

    LinkButton LNK = new LinkButton();
    LNK.ID = string.Format(DataReader["Project_id"].ToString());
    LNK.Text = "Remove Item<BR><BR>";


    Label lb2 = new Label();
    lb2.ID = string.Format(DataReader["Project_id"].ToString());
    lb2.Text = string.Format(DataReader["Project_id"].ToString());
    lb2.CssClass = "cartLabel";
    //Add to panel.
    Panel1.Controls.Add(lb);
    Panel1.Controls.Add(LNK);


  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭John_Mc


    Darragh29 wrote: »
    This is my last question! On a Button Click, I can use:

    protected void Button1_Click(object sender, EventArgs e)

    {
    To do whatever I want to do...
    }

    But can I do the same with a LinkButton???

    Yeah you can. Just treat the Linkbutton the same as a normal button and you shouldnt have any problems.
    Darragh29 wrote: »
    Also, what's the story with having an undefined number of LinkButtons, depending on the number of items within my cart???

    I dont understand the question here?
    Darragh29 wrote: »
    Here's my code sofar...

    string newstring = string.Concat(obj1," " + obj2, " " + obj3, "<br>" + obj4, " " + obj5, "<br>Retail Price: € " + obj6,"<BR>");

    Label lb = new Label();
    lb.ID = string.Format(DataReader["Project_id"].ToString());
    lb.Text = newstring.ToString();

    LinkButton LNK = new LinkButton();
    LNK.ID = string.Format(DataReader["Project_id"].ToString());
    LNK.Text = "Remove Item<BR><BR>";


    Label lb2 = new Label();
    lb2.ID = string.Format(DataReader["Project_id"].ToString());
    lb2.Text = string.Format(DataReader["Project_id"].ToString());
    lb2.CssClass = "cartLabel";
    //Add to panel.
    Panel1.Controls.Add(lb);
    Panel1.Controls.Add(LNK);


    Why do you have lb2 there?

    I would give LNK an ID of something meaningful like "btnDelete_" + nIndex;

    I'd set the LNK.CommandName="Delete" and LNK.CommandArgument=string.Format(DataReader["Project_id"].ToString());

    Then in Button1_Click event handler, check if the CommandName is "Delete" and if so, extract the Project_id from the CommandArgument and use it to remove the item from the list.


  • Closed Accounts Posts: 7,097 ✭✭✭Darragh29


    My only issue with finishing this now is how to tie the following code:

    LinkButton Delete_Btn = new LinkButton();
    Delete_Btn.ID = string.Format(DataReader["Project_id"].ToString());
    Delete_Btn.Text = "Remove Item<BR><BR>";
    Delete_Btn.CommandName="Delete";
    Delete_Btn.CommandArgument = string.Format(DataReader["Project_id"].ToString());

    In with this event handler:

    protected void Delete_Btn_Click(object sender, EventArgs e)

    {
    Response.Write("My delete button works!");
    }

    What I'm trying to do here is just get the button to work, when I have that cracked, I can write whatever I need to write in the {} to get the record deleted, or I think I can!

    But when I do what I think I should be doing here...

    Delete_Btn.OnClientClick = Delete_Btn_Click();

    Or something to relate my Linkbutton to my event handler, I keep getting errors like, "No overload for method 'Delete_Btn_Click' takes '0' arguments"...

    I know I should take the time to sit down and get to grips with functions, methods and all that stuff, I did C and C++ in uni and just scrapped my way through it in first and second year without properly understanding how functions and methods work, I think I understood it for half an hour once and then it just slipped away again!


  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭John_Mc


    Darragh29 wrote: »
    My only issue with finishing this now is how to tie the following code:

    LinkButton Delete_Btn = new LinkButton();
    Delete_Btn.ID = string.Format(DataReader["Project_id"].ToString());
    Delete_Btn.Text = "Remove Item<BR><BR>";
    Delete_Btn.CommandName="Delete";
    Delete_Btn.CommandArgument = string.Format(DataReader["Project_id"].ToString());

    In with this event handler:

    protected void Delete_Btn_Click(object sender, EventArgs e)

    {
    Response.Write("My delete button works!");
    }

    What I'm trying to do here is just get the button to work, when I have that cracked, I can write whatever I need to write in the {} to get the record deleted, or I think I can!

    But when I do what I think I should be doing here...

    Delete_Btn.OnClientClick = Delete_Btn_Click();

    Or something to relate my Linkbutton to my event handler, I keep getting errors like, "No overload for method 'Delete_Btn_Click' takes '0' arguments"...

    I know I should take the time to sit down and get to grips with functions, methods and all that stuff, I did C and C++ in uni and just scrapped my way through it in first and second year without properly understanding how functions and methods work, I think I understood it for half an hour once and then it just slipped away again!

    It should be:

    Delete_Btn.OnClick="Delete_Btn_Click";

    Note that this is just the method name, not invoking the method like you were doing. In your case, you'd need to pass an object and event args because this is what the signature tells it to expect. By using Delete_Btn_Click() you're not passing these so that gives this takes 0 arguments error.

    Try that and let me know how it goes

    OnClientClick is for your client side Javascript functions.


  • Closed Accounts Posts: 7,097 ✭✭✭Darragh29


    John_Mc wrote: »
    It should be:

    Delete_Btn.OnClick="Delete_Btn_Click";

    Note that this is just the method name, not invoking the method like you were doing. In your case, you'd need to pass an object and event args because this is what the signature tells it to expect. By using Delete_Btn_Click() you're not passing these so that gives this takes 0 arguments error.

    Try that and let me know how it goes

    OnClientClick is for your client side Javascript functions.

    I haven't seen this error before, but this is what I'm after getting after trying the above. The reason I never tried this before I think is because when I use intellisense, the OnClick option isn't there when I type in Delete_Btn., but OnClientClick is there in the list of options I can use....

    CS0122: 'System.Web.UI.WebControls.LinkButton.OnClick(System.EventArgs)' is inaccessible due to its protection level

    :confused::confused::confused:


  • Closed Accounts Posts: 7,097 ✭✭✭Darragh29


    I've tried changing the OnClick to just Click, which is available on the intellisense list, I get the following error:

    The event 'System.Web.UI.WebControls.LinkButton.Click' can only appear on the left hand side of += or -=


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    Darragh29 wrote: »
    I haven't seen this error before, but this is what I'm after getting after trying the above. The reason I never tried this before I think is because when I use intellisense, the OnClick option isn't there when I type in Delete_Btn., but OnClientClick is there in the list of options I can use....

    CS0122: 'System.Web.UI.WebControls.LinkButton.OnClick(System.EventArgs)' is inaccessible due to its protection level

    :confused::confused::confused:

    I'd hazard a guess and say that the OnClick event is declared as private instead of protected.

    I'm a little lost on what your trying to do and its probably to late to jump in here as John_Mc is doing a good job. Sounds to me like you could use a Repeater control though, and binding a datatable to that.

    The repeater control will render all the neccessary controls and html for you and allow you to bind to events in your code behind. I've attached a simple project that demonstrates this (for future reference :)). Its vs2008, if you need an earlier version let me know.

    Just a couple of pointers for good practice, they're only small things:
    object obj1 = new object();
    obj1 = string.Format(DataReader["eq_type"].ToString())
    

    Is somewhat ineffiecent. If you going to concat strings then you should use strings. The following would be better, you don't need to use string.Format either.
    String obj1 = DataReader["eq_type"].ToString();
    


    I'd recommend avoiding the use HTML tags in your code behind too. Better to render your HTML in the aspx page, takes a little more thought but saves major headaches later on.


  • Closed Accounts Posts: 7,097 ✭✭✭Darragh29


    Thanks for that Phil, when I get my Delete_Btn working, I'll get rid of my objects as you suggested...

    What I can't understand is why I don't have an option OnClick for my Delete_Btn??? I just want to create an event hander to make something happen when the my LinkButton is clicked. I think I've the hard part done, the button appears where it should and all is well there, I just can't make it work!

    I've put in my:

    protected void Delete_Btn_Click(object sender, EventArgs e)
    {
    Response.Write("Hello World!");
    }

    And I have:

    LinkButton Delete_Btn = new LinkButton();
    Delete_Btn.ID = string.Format(DataReader["Project_id"].ToString());
    Delete_Btn.Text = "Remove Item<BR><BR>";
    Delete_Btn.CommandName="Delete";
    Delete_Btn.CommandArgument = string.Format(DataReader["Project_id"].ToString());
    Delete_Btn.OnClick += Delete_Btn_Click;

    Panel1.Controls.Add(Product_Label);
    Panel1.Controls.Add(Delete_Btn);

    I just need to connect up the two... John's been great for the help with this, I'm 99% of the way there!


  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    Delete_Btn.Click += new EventHandler(Delete_Btn_Click);
    

    Should see you right.


  • Closed Accounts Posts: 7,097 ✭✭✭Darragh29


    Thanks a mill for that Phil, it's building successfully now by the event won't fire for me...


  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    Have you put a breakpoint on the event to make sure it isn't firing?


  • Closed Accounts Posts: 7,097 ✭✭✭Darragh29


    Evil Phil wrote: »
    Have you put a breakpoint on the event to make sure it isn't firing?

    Just tried that Phil and it defo ain't firing...


  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭John_Mc


    Darragh29 wrote: »
    Just tried that Phil and it defo ain't firing...

    As I said before, this is most likely due to a problem caused by the .net page life cycle.

    Where is your method that adds the controls to the page being called? The controls need to be added to the page before the Event handler is invoked. Try putting the method call in the Page_Load event.


  • Closed Accounts Posts: 7,097 ✭✭✭Darragh29


    John_Mc wrote: »
    As I said before, this is most likely due to a problem caused by the .net page life cycle.

    Where is your method that adds the controls to the page being called? The controls need to be added to the page before the Event handler is invoked. Try putting the method call in the Page_Load event.

    Is this the method?

    LinkButton Delete_Btn = new LinkButton();

    I need to get my head around (a) Methods, (b) Arguments and (c) Functions, I don't know how I got through 2 years of uni with this!


  • Closed Accounts Posts: 7,097 ✭✭✭Darragh29


    John_Mc wrote: »
    As I said before, this is most likely due to a problem caused by the .net page life cycle.

    Where is your method that adds the controls to the page being called? The controls need to be added to the page before the Event handler is invoked. Try putting the method call in the Page_Load event.

    Hi John, I've read up on the .net page life cycle and most if not all of it has gone completely over my head!


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭John_Mc


    Yeah it's pretty confusing at first but it's imperative if you want to dynamically add controls.

    I'm not even sure if method is the correct term, but you have a piece of code that adds the controls to the page. Do you have that code in the Page_Load event or is it in its own function? If its the latter then you need to call that function within the Page_Load event.

    Basically the page is recreated every time you postback, if you don't then the event handler doesnt fire. Be sure that your code isnt within if(!IsPostback).


  • Closed Accounts Posts: 7,097 ✭✭✭Darragh29


    I think this is what you're referring to John...

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Web.Services;
    using System.Collections.Specialized;
    using AjaxControlToolkit;
    using System.Data.SqlClient;
    using System.Data.OleDb;
    using System.Web.SessionState;
    using System.Text;

    public partial class _Default : System.Web.UI.Page
    {

    protected System.Web.UI.WebControls.LinkButton Delete_Btn;


  • Closed Accounts Posts: 7,097 ✭✭✭Darragh29


    I've noticed that when I add an item to my basket and get up the "Delete" LinkButton, when I hover the mouse over the LinkButton, I get the text in the image below at the bottom of the screen. I'm wondering why "Javascript" is coming up there??? I didn't think there was any JS going on here??? :confused::confused::confused:

    Just to clarify, the number 227 in the attached image is the dynamic ID of the LinkButton as set by the line of code below...

    Delete_Btn.ID = string.Format(DataReader["Project_id"].ToString());

    This just reads a unique ID from my DB...


  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭John_Mc


    Darragh29 wrote: »
    I think this is what you're referring to John...

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Web.Services;
    using System.Collections.Specialized;
    using AjaxControlToolkit;
    using System.Data.SqlClient;
    using System.Data.OleDb;
    using System.Web.SessionState;
    using System.Text;

    public partial class _Default : System.Web.UI.Page
    {

    protected System.Web.UI.WebControls.LinkButton Delete_Btn;

    No, I was referring to the piece of code that instantiates the delete button and adds it to the panel/placeholder.

    What you've pasted there simply declares the link button, which will be null until it's instantiated.


  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭John_Mc


    Darragh29 wrote: »
    I've noticed that when I add an item to my basket and get up the "Delete" LinkButton, when I hover the mouse over the LinkButton, I get the text in the image below at the bottom of the screen. I'm wondering why "Javascript" is coming up there??? I didn't think there was any JS going on here??? :confused::confused::confused:

    Just to clarify, the number 227 in the attached image is the dynamic ID of the LinkButton as set by the line of code below...

    Delete_Btn.ID = string.Format(DataReader["Project_id"].ToString());

    This just reads a unique ID from my DB...

    When you attach an event handler to an ASP.net control it automatically renders the control with javascript (or at least a Microsoft version of JS) to do a postback.


  • Registered Users, Registered Users 2 Posts: 2,931 ✭✭✭Ginger


    You need to add the Buttons in the page lifecycle in the Init phase..

    Added controls do not survive postback as well so you need to them to the viewstate/database to make them work correctly otherwise what happens is you cannot keep an eye on them...

    Dynamically added controls can a pain to work, i just finished a project based around a whole load of them (custom user controls that you could keep adding etc to the page) and its a nightmare to get right..

    Anyways event handlers for any of the objects should be added on the Init phase.
    protected override void OnInit(EventArgs e)
            {
               //add event handlers here
    }
    

    And in the case of dynamically added objects when they are created

    You can also add a RepeaterEventHandler for your link buttom

    eg

    private void Repeater_ItemCommand(object source, RepeaterCommandEventArgs e), if you are using a custom user control (ascx) file which raises a command to the repeater


  • Advertisement
  • Closed Accounts Posts: 7,097 ✭✭✭Darragh29


    I knew I should have bought the ecommerce uncle bens boil in the bag product! :D:D:D

    I've been away from my PC since the weekend so I haven't had a chance to try this out but thanks so much to John & Ginger for the help with this... I'll get a chance tomorrow to rummage through my code and try to knock this one on the head.


  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭John_Mc


    Darragh29 wrote: »
    I knew I should have bought the ecommerce uncle bens boil in the bag product! :D:D:D

    I've been away from my PC since the weekend so I haven't had a chance to try this out but thanks so much to John & Ginger for the help with this... I'll get a chance tomorrow to rummage through my code and try to knock this one on the head.

    No problem Darragh :)

    Stick with it because once you grasp it you'll know it forever, and will have no problems creating and using your own user controls which will allow for easier reusability.


  • Closed Accounts Posts: 7,097 ✭✭✭Darragh29


    Ok, I'm going to revisit this today and see if I can get her over the fence!


  • Closed Accounts Posts: 7,097 ✭✭✭Darragh29


    Here's my main issue now... I can get the delete item function to work when I put the code for it into the Page_Load function. Now that's grand but I have it where it is, (currently in the Button1_Click function because I want it to work when an item is added to the shopping basket/cart), so that it works when the button is clicked. If I move the code to somewhere else, it simply won't work because the instance of my Linkbutton will not be created for each item that is added to my shopping basket (this happens when the Button1_Click event is triggered which works fine at the moment). I'm getting this stupid:

    CS0122: 'System.Web.UI.WebControls.LinkButton.OnClick(System.EventArgs)' is inaccessible due to its protection level

    error even though all my functions are now public after being changed from protected to public. :mad: :confused::(


  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭John_Mc


    Darragh29 wrote: »
    Here's my main issue now... I can get the delete item function to work when I put the code for it into the Page_Load function. Now that's grand but I have it where it is, (currently in the Button1_Click function because I want it to work when an item is added to the shopping basket/cart), so that it works when the button is clicked. If I move the code to somewhere else, it simply won't work because the instance of my Linkbutton will not be created for each item that is added to my shopping basket (this happens when the Button1_Click event is triggered which works fine at the moment). I'm getting this stupid:

    CS0122: 'System.Web.UI.WebControls.LinkButton.OnClick(System.EventArgs)' is inaccessible due to its protection level

    error even though all my functions are now public after being changed from protected to public. :mad: :confused::(

    I don't quite follow you there. Can you provide some code?


  • Advertisement
  • Closed Accounts Posts: 7,097 ✭✭✭Darragh29


    John_Mc wrote: »
    I don't quite follow you there. Can you provide some code?

    Here's the complete code John, from the questions I've asked so far, it seems I have to recreate the control on postback. I've tried moving my Linkbutton code out of where it is below and up into the Page_Load function and when I do this, it will work/fire as a Linkbotton, but it won't work properly in the context of the wider project, which I need to create a link button for every item in my shopping cart using the while loop below...

    The error I'm getting now on the basis of the code below is:

    'System.Web.UI.WebControls.LinkButton.OnClick(System.EventArgs)' is inaccessible due to its protection level I changed all the "protected" settings to "public" to see if that sorted it but no luck so I changed them all back to "protected"...


    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Web.Services;
    using System.Collections.Specialized;
    using AjaxControlToolkit;
    using System.Data.SqlClient;
    using System.Data.OleDb;
    using System.Web.SessionState;
    using System.Text;

    public partial class _Default : System.Web.UI.Page
    {


    public void Page_Load(object sender, EventArgs e)
    {
    if (this.Session["dummy"] == null) { this.Session["dummy"] = 1; } lblSessionID.Text = this.Session.SessionID;

    }


    protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
    {
    // Get selected values
    string make = DropDownList1.SelectedItem.Text;
    string model = DropDownList2.SelectedItem.Text;
    string color = DropDownList3.SelectedItem.Text;

    // Output result string based on which values are specified
    if (string.IsNullOrEmpty(make))
    {
    Label1.Text = "Please Select an Engine Type.";
    }
    else if (string.IsNullOrEmpty(model))
    {
    Label1.Text = "Please select a model.";
    }
    else if (string.IsNullOrEmpty(color))
    {
    Label1.Text = "Please Select a Make.";
    }
    else
    {
    string dropdowna = DropDownList1.SelectedValue;
    string dropdownb = DropDownList2.SelectedValue;
    string dropdownc = DropDownList3.SelectedValue;


    DateTime myDateTime1 = new DateTime();
    myDateTime1 = new DateTime();
    myDateTime1 = DateTime.Now;

    string selectSQL;

    //Connection for SELECT FROM "Vehicle data"
    SqlConnection connz = new SqlConnection("Data Source=My Working Connection String");
    connz.Open();

    selectSQL = "SELECT * FROM Vehicle_Data WHERE Vehicle_Make = '" + DropDownList1.SelectedItem.Value + "' AND Vehicle_Model = '" + DropDownList2.SelectedItem.Value + "' AND Engine_Type = '" + DropDownList3.SelectedItem.Value + "'";

    SqlCommand cmdy = new SqlCommand(selectSQL, connz);
    cmdy.CommandType = CommandType.Text;

    SqlDataReader myDataReader;
    myDataReader = cmdy.ExecuteReader();

    Label1.Text = string.Format("Vehicle Information: {0} {1}.", make, model);
    Label7.Text = string.Format("Engine Type: {0}.", color);

    while (myDataReader.Read())
    {
    Label2.Text = string.Format("Your Purchase ID is: {0} ", myDataReader["Stock_Code"]);
    Label12.Text = string.Format("Retail Price: €");
    Label14.Text = string.Format("Product Info: ");
    Label3.Text = string.Format("{0:F2}", myDataReader["Retail_Price"]);
    Label4.Text = string.Format("{0} ", myDataReader["Product_Description"]);
    Label5.Text = string.Format("{0} ", myDataReader["Component_Manufacturer"]);
    Label15.Text = string.Format("Manufacturer: ");
    Label6.Text = string.Format("Timestamp: {0} ", myDateTime1);

    }

    myDataReader.Close();
    connz.Close();
    }
    }

    [WebMethod]
    [System.Web.Script.Services.ScriptMethod]
    public static CascadingDropDownNameValue[] GetDropDownContentsPageMethod(string knownCategoryValues, string category)
    {
    return new CarsService().GetDropDownContents(knownCategoryValues, category);
    }

    public void Button1_Click(object sender, EventArgs e)
    {
    SqlConnection conn = new SqlConnection("Data Source=My Working Connection String");
    conn.Open();

    string TransDateTime = DateTime.UtcNow.ToString("r");
    string Delivery = string.Format("7.50");
    string dropdown1 = DropDownList1.SelectedValue;
    string dropdown2 = DropDownList2.SelectedValue;
    string dropdown3 = DropDownList3.SelectedValue;
    string Manufacturer = Label5.Text;
    string Description = Label4.Text;
    string Retail = Label3.Text;
    string SessionID = lblSessionID.Text;

    string sql = "insert into used_equipment (eq_type, eq_make, eq_model, SessionID, Retail_Price, Component_Manufacturer, Product_Description, Date_Time, Delivery_Cost)\n";
    sql += "values(";

    sql += "'" + dropdown1 + "',";
    sql += "'" + dropdown2 + "',";
    sql += "'" + dropdown3 + "',";
    sql += "'" + SessionID + "',";
    sql += "'" + Retail + "',";
    sql += "'" + Manufacturer + "',";
    sql += "'" + Description + "',";
    sql += "'" + TransDateTime + "',";
    sql += "'" + Delivery + "')";

    SqlCommand cmd = new SqlCommand(sql, conn);
    cmd.CommandType = CommandType.Text;
    cmd.ExecuteNonQuery();
    conn.Close();



    string selectSQLX;
    string selectSUM;
    string SumDelivery;

    SqlConnection connT = new SqlConnection("Data Source=My Working Connection String");
    connT.Open();

    SqlConnection connP = new SqlConnection("Data Source=My Working Connection String");
    connP.Open();

    SqlConnection connX = new SqlConnection("Data Source=My Working Connection String");
    connX.Open();

    selectSQLX = "SELECT * FROM used_equipment WHERE SessionID = '" + this.Session.SessionID + "'";
    selectSUM = "SELECT SUM(Retail_Price) FROM used_equipment WHERE SessionID = '" + this.Session.SessionID + "'";
    SumDelivery = "SELECT SUM(Delivery_Cost) FROM used_equipment WHERE SessionID = '" + this.Session.SessionID + "'";

    SqlCommand cmdy = new SqlCommand(selectSQLX, connT);
    cmdy.CommandType = CommandType.Text;

    SqlCommand cmdu = new SqlCommand(selectSUM, connP);

    SqlCommand cmdL = new SqlCommand(SumDelivery, connX);


    SqlDataReader DataReader;
    DataReader = cmdy.ExecuteReader();

    if (DataReader.HasRows)
    {
    //Label13.Text = "";

    while (DataReader.Read())
    {
    object obj1 = new object();
    obj1 = string.Format(DataReader["eq_type"].ToString());

    object obj2 = new object();
    obj2 = string.Format(DataReader["eq_make"].ToString());

    object obj3 = new object();
    obj3 = string.Format(DataReader["eq_model"].ToString());

    object obj4 = new object();
    obj4 = string.Format(DataReader["Component_Manufacturer"].ToString());

    object obj5 = new object();
    obj5 = string.Format(DataReader["Product_Description"].ToString());

    object obj6 = new object();
    obj6 = string.Format(DataReader["Retail_Price"].ToString());

    object obj7 = new object();
    obj7 = string.Format(DataReader["Project_id"].ToString());

    string newstring = string.Concat(obj1, " " + obj2, " " + obj3, "<br>" + obj4, " " + obj5, "<br>Retail Price: € " + obj6, "<BR>");

    Label Product_Label = new Label();
    Product_Label.ID = string.Format(DataReader["Project_id"].ToString());
    Product_Label.Text = newstring.ToString();

    LinkButton Delete_Btn = new LinkButton();
    Delete_Btn.ID = string.Format(DataReader["Project_ID"].ToString());
    Delete_Btn.Text = "Remove Item<BR><BR>";
    Delete_Btn.CommandName = "DeleteMe";
    Delete_Btn.PostBackUrl = "~/MainTestX.aspx";
    Delete_Btn.OnClick += new EventHandler(Delete_Btn_Click);
    Delete_Btn.CommandArgument = string.Format(DataReader["Project_id"].ToString());


    Panel1.Controls.Add(Product_Label);
    Panel1.Controls.Add(Delete_Btn);

    }

    decimal Cart = Convert.ToDecimal(cmdu.ExecuteScalar());
    decimal Carry = Convert.ToDecimal(Delivery);
    decimal Cart_Total = Cart + Carry;

    Label Shopping_Cart = new Label();
    Shopping_Cart.ID = "Cart";
    Shopping_Cart.Text = string.Format("Order Total: € {0} ", (Cart));

    Label Shipping_Label = new Label();
    Shipping_Label.ID = "Shipping";
    Shipping_Label.Text = string.Format("<BR>Shipping: € {0} ", (Carry));

    Label Order_Total = new Label();
    Order_Total.ID = "Order_Tot";
    Order_Total.Text = string.Format("<BR>Invoice Total: € {0} ", (Cart_Total));

    Panel1.Controls.Add(Shopping_Cart);
    Panel1.Controls.Add(Shipping_Label);
    Panel1.Controls.Add(Order_Total);



    }

    DataReader.Close();
    connT.Close();
    connP.Close();



    ////////////////////////////////////////////////////////////



    //End of test code block////
    }


    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }

    protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
    {

    }

    protected void Button2_Click(object sender, EventArgs e)
    {

    }

    protected void Delete_Btn_Click(object sender, EventArgs e)
    {
    Response.Write("Hello World!");
    }

    }


  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭John_Mc


    The buttons need to be created in the Page_Load event, there's no way around that. If you create them in there then you wont need to also create them in the Button Click event handler.

    What's the "the context of the wider project" that prevents you from doing this?


  • Registered Users, Registered Users 2 Posts: 2,931 ✭✭✭Ginger


    If it was me, I would be doing this a slightly different way and throwing the whole thing in a repeater and you could then add a repeater command event to handle what happened with each link..

    This would then process all your information easier and give you some control


  • Closed Accounts Posts: 7,097 ✭✭✭Darragh29


    John_Mc wrote: »
    The buttons need to be created in the Page_Load event, there's no way around that. If you create them in there then you wont need to also create them in the Button Click event handler.

    What's the "the context of the wider project" that prevents you from doing this?

    I hope I can explain this right... As I see it, (going back to my very limited knowledge of C from long ago!), to create several instances of this Linkbutton, as I am doing (even though it doesn't "work" yet!), but to get one instance of the button created for each item in my shopping cart, I have to use a while loop as I have done to step through each item in the cart and at the same time create a Linkbutton to delete an item if required. Is there a way I can "Create" or "declare" the Linkbutton in the Page_Load function but actually "call" it in my while loop where I need it to be, in another function??? :confused::confused::confused:


  • Closed Accounts Posts: 7,097 ✭✭✭Darragh29


    Ginger wrote: »
    If it was me, I would be doing this a slightly different way and throwing the whole thing in a repeater and you could then add a repeater command event to handle what happened with each link..

    This would then process all your information easier and give you some control

    I think I might try this Ginger, I'm not making much headway on this one as I'm trying to solve it at the moment. I've read up on a tutorial that deals with this very problem that I'm having but it sounds a bit hairy to be honest!

    http://weblogs.asp.net/infinitiesloop/archive/2006/08/25/TRULY-Understanding-Dynamic-Controls-_2800_Part-1_2900_.aspx


  • Registered Users, Registered Users 2 Posts: 2,931 ✭✭✭Ginger


    Used that blog post to help with my understading of it

    I have made something similar and used a repeater with generic methods to handle the different number of controls I needed. All sitting in an AJAX tab control...

    the main premise is this

    You have a repeater which is bound to a list of items

    When you want to add a new item you a copy of the current list which is just a query on the repeater (ie get the number of items in the repeater)

    You copy that list and add your value and then bind your repeater to the list you just added to

    So that way all items are kept in viewstate without needing to ever worry because to get the list of items you just query the current repeater

    The idea for the delete is similar

    Delete works by you adding a command and there is a repeater item event to handle this event..

    You delete by index value so you get that from e.ItemIndex allowing you to delete the correct one

    For example

    you could have a number of textboxes to show and have their data stored in a List<string>

    So you have 10 textboxes with 10 values in your generic list

    You click the btn to add a new text box

    You get the current list of text boxes by getting all the text boxes in your repeater and copying the .Text property into the List<string>

    You take that list and add a new empty string to it

    You rebind your repeater to the List<string> from the above step

    You now have 11 textboxes 1 which is empty

    You decide to delete the one at position 2 (ie third one)

    You get teh current list again

    you get the ItemIndex of the link that raised the event and do a List.DeleteAt(e.ItemIndex) to remove the value

    You rebind and you have 10 boxes again

    The values of the text boxes are stored in the list not the text box itself if you get me

    Now say you want something more complex..

    Well you create the object with the different properties and then put that in a list instead...

    You can then have a user control that represents your object and have it bind to your object (not the list)


  • Closed Accounts Posts: 7,097 ✭✭✭Darragh29


    Jesus that sounds seriously scary! I think I'm going to go back to PHP, I've run out of patience with the endless complications with ASP.NET. I think unless you have a seriously strong programming background, (which I don't have!), the lesson I've learnt is best avoid C# and asp.net!


  • Registered Users, Registered Users 2 Posts: 2,931 ✭✭✭Ginger


    Ok calm down

    Tis not complex, its quite simple to get..

    the idea is you get a list of items, add a value and give the list back to the thingy to work on.. sorta like any list you would use

    Right some sample code

    First the repeater which holds a placeholder for all the controls to be placed in it.

    I have a usercontrol called FExpertControl that I use to show the data from an FExpert object.
    
    <asp:Repeater ID="rptExpert" runat="server">
                            <ItemTemplate>
                                <asp:PlaceHolder ID="phExpert" runat="server"></asp:PlaceHolder>    
                            </ItemTemplate>
                        </asp:Repeater>
    
    

    I have in the code behind a List<FExpert> that handles the objects.

    in the OnInit part of the page life i add 2 event handlers to the repeater
    rptExpert.ItemCreated += RptExpertItemCreated;
                rptExpert.ItemCommand += RptExpertItemCommand;
    
    

    The ItemCreated is for add, the ItemCommand is for delete (or other things)

    The event handlers
    
     private void RptExpertItemCommand(object source, RepeaterCommandEventArgs e)
            {
                RemoveItem(rptExpert, CurrentExpertData, e);
            }
    
            private void RptExpertItemCreated(object sender, RepeaterItemEventArgs e)
            {
                AddControl<Expert>("~/Custom_Controls/FEControl.ascx", "phExpert", e);
            }
    
    

    Also I have a method to add the values to the list
    protected void AddExpert(object sender, EventArgs e)
            {
                AddItem(CurrentExpertData, rptExpert);
            }
    

    Now I have 2 generic methods that take care of what I need to do (I have about 10 different ASCX files for different objects on this page)

    They just take which repeater and what controls I want to use and do the neccessary to them

    Now you will see that this seems complex, but its not, you are just using a repeater like a database


  • Closed Accounts Posts: 7,097 ✭✭✭Darragh29


    Ginger wrote: »
    Ok calm down

    Tis not complex, its quite simple to get..

    the idea is you get a list of items, add a value and give the list back to the thingy to work on.. sorta like any list you would use

    Right some sample code

    First the repeater which holds a placeholder for all the controls to be placed in it.

    I have a usercontrol called FExpertControl that I use to show the data from an FExpert object.
    
    <asp:Repeater ID="rptExpert" runat="server">
                            <ItemTemplate>
                                <asp:PlaceHolder ID="phExpert" runat="server"></asp:PlaceHolder>    
                            </ItemTemplate>
                        </asp:Repeater>
    
    

    I have in the code behind a List<FExpert> that handles the objects.

    in the OnInit part of the page life i add 2 event handlers to the repeater
    rptExpert.ItemCreated += RptExpertItemCreated;
                rptExpert.ItemCommand += RptExpertItemCommand;
    
    

    The ItemCreated is for add, the ItemCommand is for delete (or other things)

    The event handlers
    
     private void RptExpertItemCommand(object source, RepeaterCommandEventArgs e)
            {
                RemoveItem(rptExpert, CurrentExpertData, e);
            }
    
            private void RptExpertItemCreated(object sender, RepeaterItemEventArgs e)
            {
                AddControl<Expert>("~/Custom_Controls/FEControl.ascx", "phExpert", e);
            }
    
    

    Also I have a method to add the values to the list
    protected void AddExpert(object sender, EventArgs e)
            {
                AddItem(CurrentExpertData, rptExpert);
            }
    

    Now I have 2 generic methods that take care of what I need to do (I have about 10 different ASCX files for different objects on this page)

    They just take which repeater and what controls I want to use and do the neccessary to them

    Now you will see that this seems complex, but its not, you are just using a repeater like a database

    On that blog I mentioned above for the Dynamic Controls, there was a lot of talk about something you've mentioned above, the ascx page... According to his blog, I just need to create the control for the Linkbutton I need in an ascx page (I think), and then it is added to the control tree or recreated programatically on postback... I'm just afraid that all I need, over and above what I've done to date, is one or two lines of code to get this over the fence... What I have works perfectly except for the last little bit! :confused::confused::confused:


  • Registered Users, Registered Users 2 Posts: 2,931 ✭✭✭Ginger


    Also the List on the page is this

    private List<Expert> CurrentExpertData
    {
    get { return GetItemList<Expert>(rptExpert, "phExpert"); }
    }

    GetItemList is a generic method to read the repeater and the placeholder and return the objects in a List


  • Advertisement
Advertisement