By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,836 Members | 2,059 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,836 IT Pros & Developers. It's quick & easy.

Attaching Event With Parameters to image control created dynamicll

P: n/a
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...
Nov 19 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
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" <We*******@discussions.microsoft.com> wrote in message
news:43**********************************@microsof t.com...
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...

Nov 19 '05 #2

P: n/a
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" <We*******@discussions.microsoft.com> wrote in message
news:43**********************************@microsof t.com...
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...


Nov 19 '05 #3

P: n/a
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" <We*******@discussions.microsoft.com> wrote in message
news:9A**********************************@microsof t.com...
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" <We*******@discussions.microsoft.com> wrote in message
news:43**********************************@microsof t.com...
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...


Nov 19 '05 #4

P: n/a
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" <We*******@discussions.microsoft.com> wrote in message
news:9A**********************************@microsof t.com...
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" <We*******@discussions.microsoft.com> wrote in message
news:43**********************************@microsof t.com...
> 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...


Nov 19 '05 #5

P: n/a
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" <We*******@discussions.microsoft.com> wrote in message
news:67**********************************@microsof t.com...
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" <We*******@discussions.microsoft.com> wrote in message
news:9A**********************************@microsof t.com...
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" <We*******@discussions.microsoft.com> wrote in message
> news:43**********************************@microsof t.com...
> > 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...
>
>
>


Nov 19 '05 #6

P: n/a
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" <We*******@discussions.microsoft.com> wrote in message
news:67**********************************@microsof t.com...
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" <We*******@discussions.microsoft.com> wrote in message
news:9A**********************************@microsof t.com...
> 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" <We*******@discussions.microsoft.com> wrote in message
> > news:43**********************************@microsof t.com...
> > > 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...
> >
> >
> >


Nov 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.