Repeater

Discussion in 'ASP .Net Web Controls' started by Peter Kirk, Oct 5, 2005.

  1. Peter Kirk

    Peter Kirk Guest

    Hi there

    I have some c# code which extracts a list of data (an array of Port objects)
    from a database, and I need to display this data on an asp, where the user
    can see and edit the data (and press a "save" button to write changes back
    to the database).

    I am using a "repeater" to list the Port items on the page, where some of
    the attributes of the Port objects are textboxes where the user can edit the
    data.

    My problem is the "save" button - for this I have an onclick handler, but
    how does the list of Port objects get supplied to the onclick method so I
    can write to the database?

    Thanks for any help,
    Peter
     
    Peter Kirk, Oct 5, 2005
    #1
    1. Advertising

  2. Peter,

    The Save button is a single button and is not repeated, correct?

    In the button's Click event, declare textbox variables that correspond to
    the textboxes in each row of the repeater.

    foreach(RepeaterItem rItem in rptRepeater.Items)
    {
    txtPort1 = (TextBox)rItem.FindControl("txtPortName");
    txtPort2 = (TextBox)rItem.FindControl("txtPortPrice"); //Other
    processing. }Where I've written 'other processing', you can take the
    values in the textboxes, and save them back to the database. This will get
    performed for each row of the repeater.
    HTH
    S.M. Altaf - MVP VB

    --------------------------------------------------------------------------------
    All that glitters has a high refractive index.
    www.mendhak.com






    "Peter Kirk" <> wrote in message
    news:...
    > Hi there
    >
    > I have some c# code which extracts a list of data (an array of Port
    > objects) from a database, and I need to display this data on an asp, where
    > the user can see and edit the data (and press a "save" button to write
    > changes back to the database).
    >
    > I am using a "repeater" to list the Port items on the page, where some of
    > the attributes of the Port objects are textboxes where the user can edit
    > the data.
    >
    > My problem is the "save" button - for this I have an onclick handler, but
    > how does the list of Port objects get supplied to the onclick method so I
    > can write to the database?
    >
    > Thanks for any help,
    > Peter
    >
    >
     
    S.M. Altaf [MVP], Oct 5, 2005
    #2
    1. Advertising

  3. Peter Kirk

    Peter Kirk Guest

    "S.M. Altaf [MVP]" <> skrev i en meddelelse
    news:%...
    > Peter,
    >
    > The Save button is a single button and is not repeated, correct?
    >
    > In the button's Click event, declare textbox variables that correspond to
    > the textboxes in each row of the repeater.
    >
    > foreach(RepeaterItem rItem in rptRepeater.Items)
    > {
    > txtPort1 = (TextBox)rItem.FindControl("txtPortName");
    > txtPort2 = (TextBox)rItem.FindControl("txtPortPrice"); //Other
    > processing. }Where I've written 'other processing', you can take the
    > values in the textboxes, and save them back to the database. This will
    > get performed for each row of the repeater.
    > HTH
    > S.M. Altaf - MVP VB


    Great, thanks.
    Peter
     
    Peter Kirk, Oct 5, 2005
    #3
  4. Peter Kirk

    Peter Kirk Guest

    "S.M. Altaf [MVP]" <> skrev i en meddelelse
    news:%...
    > Peter,
    >
    > The Save button is a single button and is not repeated, correct?


    The save button is in the "Footer" section of the repeater.
    Do you know how I can stop the footer from being processed if the repeater
    list is empty? For example, if there is no list then I don't want the save
    button to be dsiplayed.

    Thanks,
    Peter
     
    Peter Kirk, Oct 6, 2005
    #4
  5. Peter Kirk

    Peter Kirk Guest

    "Peter Kirk" <> skrev i en meddelelse
    news:...
    >
    > "S.M. Altaf [MVP]" <> skrev i en meddelelse
    > news:%...
    >> Peter,
    >>
    >> The Save button is a single button and is not repeated, correct?

    >
    > The save button is in the "Footer" section of the repeater.
    > Do you know how I can stop the footer from being processed if the repeater
    > list is empty? For example, if there is no list then I don't want the save
    > button to be dsiplayed.


    OK, I found out I can check <% if (myList.Items.Count > 0) ....
     
    Peter Kirk, Oct 6, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    878
  2. Replies:
    0
    Views:
    2,905
  3. Replies:
    1
    Views:
    7,048
    Karl Seguin
    Aug 10, 2005
  4. uncensored
    Replies:
    0
    Views:
    830
    uncensored
    Oct 25, 2006
  5. Microsoft

    Repeater inside a Repeater

    Microsoft, Aug 21, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    216
    Microsoft
    Aug 21, 2006
Loading...

Share This Page