Attaching Event With Parameters to image control created dynamicll

Discussion in 'ASP .Net' started by =?Utf-8?B?V2ViTWF0cml4?=, Dec 6, 2004.

  1. Hello,

    Here's the situation (I'll try to be brief as possible)
    I am working on the control which is created dynamically based on XML
    string. This control consists of a table with number of rows with 3 columns;
    TextBox, dropdown and a button ("Delete" button) in each column. Also there's
    one button at the bottom of the table that allows users to add more rows. So
    more controls will be added programmatically as user adds more rows.
    What's the easiest way to associate an event with each Delete button which
    will take rowID as a parameter. So when a particular button is clicked
    appropriate row will be removed.

    Thank you guys for any feedback...
     
    =?Utf-8?B?V2ViTWF0cml4?=, Dec 6, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?V2ViTWF0cml4?=

    Karl Seguin Guest

    Why not use a repeater and simply use the ItemCommand event of the repeater?

    The delete button's event will bubble up to the ItemCommand event, which you
    can catch, and figure out which row was clicked via a number of ways
    (commandARgument, using a hidden field)...

    You can check out more about this at:
    http://openmymind.net/databinding/index.html#8 (might wanna read the whole
    thing though).

    Karl
    --
    MY ASP.Net tutorials
    http://www.openmymind.net/


    "WebMatrix" <> wrote in message
    news:...
    > Hello,
    >
    > Here's the situation (I'll try to be brief as possible)
    > I am working on the control which is created dynamically based on XML
    > string. This control consists of a table with number of rows with 3

    columns;
    > TextBox, dropdown and a button ("Delete" button) in each column. Also

    there's
    > one button at the bottom of the table that allows users to add more rows.

    So
    > more controls will be added programmatically as user adds more rows.
    > What's the easiest way to associate an event with each Delete button which
    > will take rowID as a parameter. So when a particular button is clicked
    > appropriate row will be removed.
    >
    > Thank you guys for any feedback...
     
    Karl Seguin, Dec 6, 2004
    #2
    1. Advertising

  3. Re: Attaching Event With Parameters to image control created dynam

    Thank you for your response.

    I guess data Repeater could work, but .....
    This control is a little more complicated than simply displaying rows of
    data and deleting one row at a time:
    1. It's source is a custom XML string (I guess I has to be converted to
    dataset to be databound.)
    2. Dropdown is driven by data that varies by RowID
    3. After user adds new row or removes existing rows each row must be
    validated.

    I am not sure if Repeater can satisfy these requirements. I'd rather develop
    my own logic that parses XML and creates each control programmatically. I
    will look into repeater if nothing else works. Thanks.
    Any other sugestions?

    "Karl Seguin" wrote:

    > Why not use a repeater and simply use the ItemCommand event of the repeater?
    >
    > The delete button's event will bubble up to the ItemCommand event, which you
    > can catch, and figure out which row was clicked via a number of ways
    > (commandARgument, using a hidden field)...
    >
    > You can check out more about this at:
    > http://openmymind.net/databinding/index.html#8 (might wanna read the whole
    > thing though).
    >
    > Karl
    > --
    > MY ASP.Net tutorials
    > http://www.openmymind.net/
    >
    >
    > "WebMatrix" <> wrote in message
    > news:...
    > > Hello,
    > >
    > > Here's the situation (I'll try to be brief as possible)
    > > I am working on the control which is created dynamically based on XML
    > > string. This control consists of a table with number of rows with 3

    > columns;
    > > TextBox, dropdown and a button ("Delete" button) in each column. Also

    > there's
    > > one button at the bottom of the table that allows users to add more rows.

    > So
    > > more controls will be added programmatically as user adds more rows.
    > > What's the easiest way to associate an event with each Delete button which
    > > will take rowID as a parameter. So when a particular button is clicked
    > > appropriate row will be removed.
    > >
    > > Thank you guys for any feedback...

    >
    >
    >
     
    =?Utf-8?B?V2ViTWF0cml4?=, Dec 6, 2004
    #3
  4. =?Utf-8?B?V2ViTWF0cml4?=

    Karl Seguin Guest

    Re: Attaching Event With Parameters to image control created dynam

    Well, each delete button can be hooked into the same event, and you can
    simply set the RowId to the commandArgument so you'll know which row to
    delete.

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/


    "WebMatrix" <> wrote in message
    news:...
    > Thank you for your response.
    >
    > I guess data Repeater could work, but .....
    > This control is a little more complicated than simply displaying rows of
    > data and deleting one row at a time:
    > 1. It's source is a custom XML string (I guess I has to be converted to
    > dataset to be databound.)
    > 2. Dropdown is driven by data that varies by RowID
    > 3. After user adds new row or removes existing rows each row must be
    > validated.
    >
    > I am not sure if Repeater can satisfy these requirements. I'd rather

    develop
    > my own logic that parses XML and creates each control programmatically. I
    > will look into repeater if nothing else works. Thanks.
    > Any other sugestions?
    >
    > "Karl Seguin" wrote:
    >
    > > Why not use a repeater and simply use the ItemCommand event of the

    repeater?
    > >
    > > The delete button's event will bubble up to the ItemCommand event, which

    you
    > > can catch, and figure out which row was clicked via a number of ways
    > > (commandARgument, using a hidden field)...
    > >
    > > You can check out more about this at:
    > > http://openmymind.net/databinding/index.html#8 (might wanna read the

    whole
    > > thing though).
    > >
    > > Karl
    > > --
    > > MY ASP.Net tutorials
    > > http://www.openmymind.net/
    > >
    > >
    > > "WebMatrix" <> wrote in message
    > > news:...
    > > > Hello,
    > > >
    > > > Here's the situation (I'll try to be brief as possible)
    > > > I am working on the control which is created dynamically based on XML
    > > > string. This control consists of a table with number of rows with 3

    > > columns;
    > > > TextBox, dropdown and a button ("Delete" button) in each column. Also

    > > there's
    > > > one button at the bottom of the table that allows users to add more

    rows.
    > > So
    > > > more controls will be added programmatically as user adds more rows.
    > > > What's the easiest way to associate an event with each Delete button

    which
    > > > will take rowID as a parameter. So when a particular button is clicked
    > > > appropriate row will be removed.
    > > >
    > > > Thank you guys for any feedback...

    > >
    > >
    > >
     
    Karl Seguin, Dec 6, 2004
    #4
  5. Re: Attaching Event With Parameters to image control created dynam

    Ok, How can I add a dropdwon control populated by another data source to
    ItemTemplate and select one of the dropdown's item based on the value from
    database.
    All this information is contained within XML. That's why I am look for
    custom programming solution, but if Reapeter can handle above requirement,
    I'll go with that.

    "Karl Seguin" wrote:

    > Well, each delete button can be hooked into the same event, and you can
    > simply set the RowId to the commandArgument so you'll know which row to
    > delete.
    >
    > Karl
    >
    > --
    > MY ASP.Net tutorials
    > http://www.openmymind.net/
    >
    >
    > "WebMatrix" <> wrote in message
    > news:...
    > > Thank you for your response.
    > >
    > > I guess data Repeater could work, but .....
    > > This control is a little more complicated than simply displaying rows of
    > > data and deleting one row at a time:
    > > 1. It's source is a custom XML string (I guess I has to be converted to
    > > dataset to be databound.)
    > > 2. Dropdown is driven by data that varies by RowID
    > > 3. After user adds new row or removes existing rows each row must be
    > > validated.
    > >
    > > I am not sure if Repeater can satisfy these requirements. I'd rather

    > develop
    > > my own logic that parses XML and creates each control programmatically. I
    > > will look into repeater if nothing else works. Thanks.
    > > Any other sugestions?
    > >
    > > "Karl Seguin" wrote:
    > >
    > > > Why not use a repeater and simply use the ItemCommand event of the

    > repeater?
    > > >
    > > > The delete button's event will bubble up to the ItemCommand event, which

    > you
    > > > can catch, and figure out which row was clicked via a number of ways
    > > > (commandARgument, using a hidden field)...
    > > >
    > > > You can check out more about this at:
    > > > http://openmymind.net/databinding/index.html#8 (might wanna read the

    > whole
    > > > thing though).
    > > >
    > > > Karl
    > > > --
    > > > MY ASP.Net tutorials
    > > > http://www.openmymind.net/
    > > >
    > > >
    > > > "WebMatrix" <> wrote in message
    > > > news:...
    > > > > Hello,
    > > > >
    > > > > Here's the situation (I'll try to be brief as possible)
    > > > > I am working on the control which is created dynamically based on XML
    > > > > string. This control consists of a table with number of rows with 3
    > > > columns;
    > > > > TextBox, dropdown and a button ("Delete" button) in each column. Also
    > > > there's
    > > > > one button at the bottom of the table that allows users to add more

    > rows.
    > > > So
    > > > > more controls will be added programmatically as user adds more rows.
    > > > > What's the easiest way to associate an event with each Delete button

    > which
    > > > > will take rowID as a parameter. So when a particular button is clicked
    > > > > appropriate row will be removed.
    > > > >
    > > > > Thank you guys for any feedback...
    > > >
    > > >
    > > >

    >
    >
    >
     
    =?Utf-8?B?V2ViTWF0cml4?=, Dec 6, 2004
    #5
  6. =?Utf-8?B?V2ViTWF0cml4?=

    Karl Seguin Guest

    Re: Attaching Event With Parameters to image control created dynam

    If you are using a Repeater, you can hook into the ItemDataBound event and
    easily do that in codebehind (the tutorial I pointed you to has details on
    that), something like:

    sub ItemDataBound(...)
    dim ddl as DropDownList = ctype(e.Item.FindControl("dropdown"),
    DropDownList)
    ddl.DataSource = yourOtherDataSource;
    ddl.DataBind()
    ddl.SelectedIndex = ddl.Items.IndexOf(ddl.Items.FindByValue("TheValue"))
    end sub

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/


    "WebMatrix" <> wrote in message
    news:...
    > Ok, How can I add a dropdwon control populated by another data source to
    > ItemTemplate and select one of the dropdown's item based on the value from
    > database.
    > All this information is contained within XML. That's why I am look for
    > custom programming solution, but if Reapeter can handle above requirement,
    > I'll go with that.
    >
    > "Karl Seguin" wrote:
    >
    > > Well, each delete button can be hooked into the same event, and you can
    > > simply set the RowId to the commandArgument so you'll know which row to
    > > delete.
    > >
    > > Karl
    > >
    > > --
    > > MY ASP.Net tutorials
    > > http://www.openmymind.net/
    > >
    > >
    > > "WebMatrix" <> wrote in message
    > > news:...
    > > > Thank you for your response.
    > > >
    > > > I guess data Repeater could work, but .....
    > > > This control is a little more complicated than simply displaying rows

    of
    > > > data and deleting one row at a time:
    > > > 1. It's source is a custom XML string (I guess I has to be converted

    to
    > > > dataset to be databound.)
    > > > 2. Dropdown is driven by data that varies by RowID
    > > > 3. After user adds new row or removes existing rows each row must be
    > > > validated.
    > > >
    > > > I am not sure if Repeater can satisfy these requirements. I'd rather

    > > develop
    > > > my own logic that parses XML and creates each control

    programmatically. I
    > > > will look into repeater if nothing else works. Thanks.
    > > > Any other sugestions?
    > > >
    > > > "Karl Seguin" wrote:
    > > >
    > > > > Why not use a repeater and simply use the ItemCommand event of the

    > > repeater?
    > > > >
    > > > > The delete button's event will bubble up to the ItemCommand event,

    which
    > > you
    > > > > can catch, and figure out which row was clicked via a number of ways
    > > > > (commandARgument, using a hidden field)...
    > > > >
    > > > > You can check out more about this at:
    > > > > http://openmymind.net/databinding/index.html#8 (might wanna read the

    > > whole
    > > > > thing though).
    > > > >
    > > > > Karl
    > > > > --
    > > > > MY ASP.Net tutorials
    > > > > http://www.openmymind.net/
    > > > >
    > > > >
    > > > > "WebMatrix" <> wrote in message
    > > > > news:...
    > > > > > Hello,
    > > > > >
    > > > > > Here's the situation (I'll try to be brief as possible)
    > > > > > I am working on the control which is created dynamically based on

    XML
    > > > > > string. This control consists of a table with number of rows with

    3
    > > > > columns;
    > > > > > TextBox, dropdown and a button ("Delete" button) in each column.

    Also
    > > > > there's
    > > > > > one button at the bottom of the table that allows users to add

    more
    > > rows.
    > > > > So
    > > > > > more controls will be added programmatically as user adds more

    rows.
    > > > > > What's the easiest way to associate an event with each Delete

    button
    > > which
    > > > > > will take rowID as a parameter. So when a particular button is

    clicked
    > > > > > appropriate row will be removed.
    > > > > >
    > > > > > Thank you guys for any feedback...
    > > > >
    > > > >
    > > > >

    > >
    > >
    > >
     
    Karl Seguin, Dec 6, 2004
    #6
  7. Re: Attaching Event With Parameters to image control created dynam

    I just glimpsed over your tutorial... I think it's exactly what I was looking
    for!! and it's a great tutorial, very concise and to the point. Thanks.
    I can put together dataReapeter with nested databinding, no problems. Now I
    need to figure out how to retrieve all the data entered into the repeater's
    controls. I think I have some ideas on how do to that, pobably looping
    through ItemTemplates and .FindControls for what I need, right? I have a
    feeling I'll be posting again.


    "Karl Seguin" wrote:

    > If you are using a Repeater, you can hook into the ItemDataBound event and
    > easily do that in codebehind (the tutorial I pointed you to has details on
    > that), something like:
    >
    > sub ItemDataBound(...)
    > dim ddl as DropDownList = ctype(e.Item.FindControl("dropdown"),
    > DropDownList)
    > ddl.DataSource = yourOtherDataSource;
    > ddl.DataBind()
    > ddl.SelectedIndex = ddl.Items.IndexOf(ddl.Items.FindByValue("TheValue"))
    > end sub
    >
    > Karl
    >
    > --
    > MY ASP.Net tutorials
    > http://www.openmymind.net/
    >
    >
    > "WebMatrix" <> wrote in message
    > news:...
    > > Ok, How can I add a dropdwon control populated by another data source to
    > > ItemTemplate and select one of the dropdown's item based on the value from
    > > database.
    > > All this information is contained within XML. That's why I am look for
    > > custom programming solution, but if Reapeter can handle above requirement,
    > > I'll go with that.
    > >
    > > "Karl Seguin" wrote:
    > >
    > > > Well, each delete button can be hooked into the same event, and you can
    > > > simply set the RowId to the commandArgument so you'll know which row to
    > > > delete.
    > > >
    > > > Karl
    > > >
    > > > --
    > > > MY ASP.Net tutorials
    > > > http://www.openmymind.net/
    > > >
    > > >
    > > > "WebMatrix" <> wrote in message
    > > > news:...
    > > > > Thank you for your response.
    > > > >
    > > > > I guess data Repeater could work, but .....
    > > > > This control is a little more complicated than simply displaying rows

    > of
    > > > > data and deleting one row at a time:
    > > > > 1. It's source is a custom XML string (I guess I has to be converted

    > to
    > > > > dataset to be databound.)
    > > > > 2. Dropdown is driven by data that varies by RowID
    > > > > 3. After user adds new row or removes existing rows each row must be
    > > > > validated.
    > > > >
    > > > > I am not sure if Repeater can satisfy these requirements. I'd rather
    > > > develop
    > > > > my own logic that parses XML and creates each control

    > programmatically. I
    > > > > will look into repeater if nothing else works. Thanks.
    > > > > Any other sugestions?
    > > > >
    > > > > "Karl Seguin" wrote:
    > > > >
    > > > > > Why not use a repeater and simply use the ItemCommand event of the
    > > > repeater?
    > > > > >
    > > > > > The delete button's event will bubble up to the ItemCommand event,

    > which
    > > > you
    > > > > > can catch, and figure out which row was clicked via a number of ways
    > > > > > (commandARgument, using a hidden field)...
    > > > > >
    > > > > > You can check out more about this at:
    > > > > > http://openmymind.net/databinding/index.html#8 (might wanna read the
    > > > whole
    > > > > > thing though).
    > > > > >
    > > > > > Karl
    > > > > > --
    > > > > > MY ASP.Net tutorials
    > > > > > http://www.openmymind.net/
    > > > > >
    > > > > >
    > > > > > "WebMatrix" <> wrote in message
    > > > > > news:...
    > > > > > > Hello,
    > > > > > >
    > > > > > > Here's the situation (I'll try to be brief as possible)
    > > > > > > I am working on the control which is created dynamically based on

    > XML
    > > > > > > string. This control consists of a table with number of rows with

    > 3
    > > > > > columns;
    > > > > > > TextBox, dropdown and a button ("Delete" button) in each column.

    > Also
    > > > > > there's
    > > > > > > one button at the bottom of the table that allows users to add

    > more
    > > > rows.
    > > > > > So
    > > > > > > more controls will be added programmatically as user adds more

    > rows.
    > > > > > > What's the easiest way to associate an event with each Delete

    > button
    > > > which
    > > > > > > will take rowID as a parameter. So when a particular button is

    > clicked
    > > > > > > appropriate row will be removed.
    > > > > > >
    > > > > > > Thank you guys for any feedback...
    > > > > >
    > > > > >
    > > > > >
    > > >
    > > >
    > > >

    >
    >
    >
     
    =?Utf-8?B?V2ViTWF0cml4?=, Dec 7, 2004
    #7
    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. Cowboy \(Gregory A. Beamer\)

    Attaching to event in container object

    Cowboy \(Gregory A. Beamer\), Oct 24, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    369
    Cowboy \(Gregory A. Beamer\)
    Oct 28, 2003
  2. Per
    Replies:
    1
    Views:
    365
    Howard
    Apr 18, 2005
  3. odelya
    Replies:
    0
    Views:
    261
    odelya
    May 8, 2007
  4. =?Utf-8?B?RGF2ZQ==?=

    attaching an event to ServerValidate

    =?Utf-8?B?RGF2ZQ==?=, May 15, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    414
    =?Utf-8?B?S2VpdGg=?=
    May 15, 2007
  5. Replies:
    4
    Views:
    115
Loading...

Share This Page