Handling a button in repeater
Any advice on the following please?
Got a repeater on my page listing records from a database.
I slot a button in the last column which takes the record unique ID as
When the button is clicked it calls a function and passes the ID
Sub FuncName(ByVal sender as system.object, ByVal e as
Dim btn as Button
IDdata = btn.CommandName
IDdata is then used to query a database to return all the record
details for that unique ID
I get the error of "Object reference not set to an instance of an
object". I'm definetly pulling a value out because the following test
prints the value to the screen.
TextBox.text = IDdata
Re: Handling a button in repeater
Dstl, What is button supposed to be ?
You have declared a button, and then you are tyring to access its
commandName attribute. Its normal you are getting that error. First of all
your button is not instantiated. You have only declared a button. To
instantiate it, you should use the new keyword on your button declaration
which will create a new button for you, which is not what you want anyway,
but will get rid of that error.
what you want to do instead is get the CommandName you stored within the
button in your repeater control, and get this CommandName when that button
is clicked, if i'm not wrong and your repeater exposes a few events for this
For a click event fired you could use the onItemCommand method and code
here, this will fire for postbacks generated from within your repeater
Sub R1_ItemCommand(Sender As Object, e As RepeaterCommandEventArgs)
dim IDData as string
IDData = CType(e.CommandSource, Button).CommandName
or use the onItemCreated method which fires when the items within the
repeater control are created. Or the onItemDataBound method when the
repeater binds to a datasource --
"Dstl Web Team" <email@example.com> wrote in message
> Any advice on the following please?
> Got a repeater on my page listing records from a database.
> I slot a button in the last column which takes the record unique ID as
> it's CommandName.
> When the button is clicked it calls a function and passes the ID
> Sub FuncName(ByVal sender as system.object, ByVal e as
> Dim btn as Button
> Dim IDdata
> IDdata = btn.CommandName
> IDdata is then used to query a database to return all the record
> details for that unique ID
> End FuncName.
> I get the error of "Object reference not set to an instance of an
> object". I'm definetly pulling a value out because the following test
> prints the value to the screen.
> TextBox.text = IDdata
|All times are GMT. The time now is 08:44 AM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.