Saturday, March 31, 2012

Triggering event, listbox

For some reason I cannot get the OnSelectedIndexChanged event to fire for a
listbox I have on a page. I'm able to populate the listbox with data from a
stored procedure, but cannot trigger the event. I do have EnableViewState =
True for the listbox. I'm imagining (wanting) to populate the listbox named:
lstNames by using the DataValueField from lstDepartments.
It's quite apparent though that the event is not triggering as I can misname
the stored procedure and no error occurs.
Here is the code, I'm sure it will wrap terribly however::
MGSurvey.aspx:
<FORM id="MGSurvey" runat="server">
<p style="Z-INDEX: 101; LEFT: 15px; POSITION: relative">
<asp:listbox id="lstDepartments" style="Z-INDEX: 102; POSITION: relative;
TOP: 6px" runat="server" EnableViewState="true" OnSelectedIndexChanged =
"lstDepartments_SelectedIndexChanged" Width="258px"
Height="118px"></asp:listbox>
<asp:panel id="pnDepartmentMembers" style="Z-INDEX: 103; POSITION: relative"
runat="server" Width="559px" Height="144px" BackColor="Transparent"
BorderColor="Transparent">
<asp:listbox id="lstNames" style="Z-INDEX: 103; LEFT: 15px; POSITION:
relative; TOP: 20px" runat="server" Width="258px" EnableViewState="True"
BackColor="Transparent"></asp:listbox>
</asp:panel>
</p>
</FORM>
MGSurvey.aspx.vb:
Public Sub lstDepartments_SelectedIndexChanged(ByVa
l sender As Object, ByVal
e As EventArgs)
If (Not IsPostBack) Then
adoConn.Open()
Dim adoCommDeptMembers As New SqlCommand("dbo.MG_EmployeesByDepartment "
& lstDepartments.SelectedItem.Value, adoConn)
With lstNames
.DataSource =
adoCommDeptMembers.ExecuteReader(CommandBehavior.CloseConnection)
.DataTextField = "Name"
.DataValueField = "tp_ID"
.DataBind()
End With
adoConn.Close()
End If
End SubHow is the user triggering a postback to the server?
What happens when the page posts back to the server? What does it all look
like?
"Steve Schroeder" <sschroeder@.somewhere.com> wrote in message
news:ez4PuKNrFHA.260@.TK2MSFTNGP11.phx.gbl...
> For some reason I cannot get the OnSelectedIndexChanged event to fire for
> a
> listbox I have on a page. I'm able to populate the listbox with data from
> a
> stored procedure, but cannot trigger the event. I do have EnableViewState
> =
> True for the listbox. I'm imagining (wanting) to populate the listbox
> named:
> lstNames by using the DataValueField from lstDepartments.
> It's quite apparent though that the event is not triggering as I can
> misname
> the stored procedure and no error occurs.
> Here is the code, I'm sure it will wrap terribly however::
> MGSurvey.aspx:
> <FORM id="MGSurvey" runat="server">
> <p style="Z-INDEX: 101; LEFT: 15px; POSITION: relative">
> <asp:listbox id="lstDepartments" style="Z-INDEX: 102; POSITION: relative;
> TOP: 6px" runat="server" EnableViewState="true" OnSelectedIndexChanged =
> "lstDepartments_SelectedIndexChanged" Width="258px"
> Height="118px"></asp:listbox>
> <asp:panel id="pnDepartmentMembers" style="Z-INDEX: 103; POSITION:
> relative"
> runat="server" Width="559px" Height="144px" BackColor="Transparent"
> BorderColor="Transparent">
> <asp:listbox id="lstNames" style="Z-INDEX: 103; LEFT: 15px; POSITION:
> relative; TOP: 20px" runat="server" Width="258px" EnableViewState="True"
> BackColor="Transparent"></asp:listbox>
> </asp:panel>
> </p>
> </FORM>
> MGSurvey.aspx.vb:
> Public Sub lstDepartments_SelectedIndexChanged(ByVa
l sender As Object,
> ByVal
> e As EventArgs)
> If (Not IsPostBack) Then
> adoConn.Open()
> Dim adoCommDeptMembers As New SqlCommand("dbo.MG_EmployeesByDepartment
> "
> & lstDepartments.SelectedItem.Value, adoConn)
> With lstNames
> .DataSource =
> adoCommDeptMembers.ExecuteReader(CommandBehavior.CloseConnection)
> .DataTextField = "Name"
> .DataValueField = "tp_ID"
> .DataBind()
> End With
> adoConn.Close()
> End If
> End Sub
>
Well, I have two listboxes.
lstDepartments - Lists Departments
lstNames - Lists Members of Departments
On Page Load lstDepartments is loaded with a list of departments, with the
department 'code' as the DataValueField.
What I want to happen is, when you click on an item in the list of
departments, lstNames gets populated with the members of that department.
Stored procedures worked, tested them, they have the proper permissions,
etc.
Just can't seem to get OnSelectedIndexChanged to fire...I've tried with 'Not
IsPostBack' and without it...not sure how else to answer your
question...thanks! :)
"Marina" <someone@.nospam.com> wrote in message
news:erppRNNrFHA.3720@.TK2MSFTNGP14.phx.gbl...
> How is the user triggering a postback to the server?
> What happens when the page posts back to the server? What does it all look
> like?
> "Steve Schroeder" <sschroeder@.somewhere.com> wrote in message
> news:ez4PuKNrFHA.260@.TK2MSFTNGP11.phx.gbl...
for
from
EnableViewState
relative;
SqlCommand("dbo.MG_EmployeesByDepartment
>
You didn't really answer my questions at all, so I'm sorry but I don't have
any ideas on how to help you.
"Steve Schroeder" <sschroeder@.somewhere.com> wrote in message
news:u0gIWTNrFHA.2768@.TK2MSFTNGP12.phx.gbl...
> Well, I have two listboxes.
> lstDepartments - Lists Departments
> lstNames - Lists Members of Departments
> On Page Load lstDepartments is loaded with a list of departments, with the
> department 'code' as the DataValueField.
> What I want to happen is, when you click on an item in the list of
> departments, lstNames gets populated with the members of that department.
> Stored procedures worked, tested them, they have the proper permissions,
> etc.
> Just can't seem to get OnSelectedIndexChanged to fire...I've tried with
> 'Not
> IsPostBack' and without it...not sure how else to answer your
> question...thanks! :)
> "Marina" <someone@.nospam.com> wrote in message
> news:erppRNNrFHA.3720@.TK2MSFTNGP14.phx.gbl...
> for
> from
> EnableViewState
> relative;
> SqlCommand("dbo.MG_EmployeesByDepartment
>
"How is the user triggering a postback to the server?" - Postback, as I unde
rstand it is triggered by reloading the page. In my case, this is not happen
ing. All the user should be doing is selecting with their mouse and item in
the listbox, and hopefully triggering the OnSelectedIndexChanged event of th
e listbox named lstDepartments.
"What happens when the page posts back to the server? What does it all look
like?" - Nothing happens, the first listbox flickers when you select an item
, and the second listbox remains empty, and no error message occurs.
"Marina" <someone@.nospam.com> wrote in message news:uJuQVWNrFHA.3444@.TK2MSFTNGP12.phx.gbl..
.
> You didn't really answer my questions at all, so I'm sorry but I don't hav
e
> any ideas on how to help you.
>
> "Steve Schroeder" <sschroeder@.somewhere.com> wrote in message
> news:u0gIWTNrFHA.2768@.TK2MSFTNGP12.phx.gbl...
>
>
Ok, so the problem is that there is no postback to the server!
A server side event can't run, unless something forces a postback to the ser
ver. Your page is sitting in the browser - whatever objects the server used
to generate the page are long gone. HTTP is a connectionless protocol - it'
s just the browser on its own.
So you need something there to trigger an event to the server.
I think the listbox may be one of the objects that has an AutoPostback prope
rty. If it does, setting this to True, will trigger a postback to the server
whenever the selected item is changed.
If the listbox does not have such a property, you need to trigger a postback
. It may be that there is a button the user has to click to proceed, or you
may have to write some javascript to trigger the post.
"Steve Schroeder" <sschroeder@.somewhere.com> wrote in message news:e0RNqcNrF
HA.1128@.TK2MSFTNGP11.phx.gbl...
"How is the user triggering a postback to the server?" - Postback, as I unde
rstand it is triggered by reloading the page. In my case, this is not happen
ing. All the user should be doing is selecting with their mouse and item in
the listbox, and hopefully triggering the OnSelectedIndexChanged event of th
e listbox named lstDepartments.
"What happens when the page posts back to the server? What does it all look
like?" - Nothing happens, the first listbox flickers when you select an item
, and the second listbox remains empty, and no error message occurs.
"Marina" <someone@.nospam.com> wrote in message news:uJuQVWNrFHA.3444@.TK2MSFTNGP12.phx.gbl..
.
> You didn't really answer my questions at all, so I'm sorry but I don't hav
e
> any ideas on how to help you.
>
> "Steve Schroeder" <sschroeder@.somewhere.com> wrote in message
> news:u0gIWTNrFHA.2768@.TK2MSFTNGP12.phx.gbl...
>
>
Well I'll be damned...that worked! Thank you!
For future reference...when would I not want to do a postback, and if 90% of
the time people do postback, why isn't it the default behavior? I would hav
e gnashed my teeth over that one indefinately...
"Marina" <someone@.nospam.com> wrote in message news:O6YP1gNrFHA.528@.TK2MSFTN
GP09.phx.gbl...
Ok, so the problem is that there is no postback to the server!
A server side event can't run, unless something forces a postback to the ser
ver. Your page is sitting in the browser - whatever objects the server used
to generate the page are long gone. HTTP is a connectionless protocol - it'
s just the browser on its own.
So you need something there to trigger an event to the server.
I think the listbox may be one of the objects that has an AutoPostback prope
rty. If it does, setting this to True, will trigger a postback to the server
whenever the selected item is changed.
If the listbox does not have such a property, you need to trigger a postback
. It may be that there is a button the user has to click to proceed, or you
may have to write some javascript to trigger the post.
"Steve Schroeder" <sschroeder@.somewhere.com> wrote in message news:e0RNqcNrF
HA.1128@.TK2MSFTNGP11.phx.gbl...
"How is the user triggering a postback to the server?" - Postback, as I unde
rstand it is triggered by reloading the page. In my case, this is not happen
ing. All the user should be doing is selecting with their mouse and item in
the listbox, and hopefully triggering the OnSelectedIndexChanged event of th
e listbox named lstDepartments.
"What happens when the page posts back to the server? What does it all look
like?" - Nothing happens, the first listbox flickers when you select an item
, and the second listbox remains empty, and no error message occurs.
"Marina" <someone@.nospam.com> wrote in message news:uJuQVWNrFHA.3444@.TK2MSFTNGP12.phx.gbl..
.
> You didn't really answer my questions at all, so I'm sorry but I don't hav
e
> any ideas on how to help you.
>
> "Steve Schroeder" <sschroeder@.somewhere.com> wrote in message
> news:u0gIWTNrFHA.2768@.TK2MSFTNGP12.phx.gbl...
>
>
Because, who is to say that you always want a postback?
A lot of times, a user is filling out a form, and has many fields to fill ou
t. Then they hit 'Submit', and go to the next page. In this case you would
not want to postback automatically. Not only because there is nothing to do
until the form is filled out, but because it is a waste of resources, and l
ooks ugly with the screen flashing all the time.
So I would say, that it is not the case that people want to postback most of
the time. It really just depends on the type of application and what the UI
needs to do.
I think most people would assume that nothing happens by default, because th
at is what HTML equivalents of these controls would do. And then they add c
ode to change the default behavior.
"Steve Schroeder" <sschroeder@.somewhere.com> wrote in message news:OFaBqoNrF
HA.2624@.TK2MSFTNGP15.phx.gbl...
Well I'll be damned...that worked! Thank you!
For future reference...when would I not want to do a postback, and if 90% of
the time people do postback, why isn't it the default behavior? I would hav
e gnashed my teeth over that one indefinately...
"Marina" <someone@.nospam.com> wrote in message news:O6YP1gNrFHA.528@.TK2MSFTN
GP09.phx.gbl...
Ok, so the problem is that there is no postback to the server!
A server side event can't run, unless something forces a postback to the ser
ver. Your page is sitting in the browser - whatever objects the server used
to generate the page are long gone. HTTP is a connectionless protocol - it'
s just the browser on its own.
So you need something there to trigger an event to the server.
I think the listbox may be one of the objects that has an AutoPostback prope
rty. If it does, setting this to True, will trigger a postback to the server
whenever the selected item is changed.
If the listbox does not have such a property, you need to trigger a postback
. It may be that there is a button the user has to click to proceed, or you
may have to write some javascript to trigger the post.
"Steve Schroeder" <sschroeder@.somewhere.com> wrote in message news:e0RNqcNrF
HA.1128@.TK2MSFTNGP11.phx.gbl...
"How is the user triggering a postback to the server?" - Postback, as I unde
rstand it is triggered by reloading the page. In my case, this is not happen
ing. All the user should be doing is selecting with their mouse and item in
the listbox, and hopefully triggering the OnSelectedIndexChanged event of th
e listbox named lstDepartments.
"What happens when the page posts back to the server? What does it all look
like?" - Nothing happens, the first listbox flickers when you select an item
, and the second listbox remains empty, and no error message occurs.
"Marina" <someone@.nospam.com> wrote in message news:uJuQVWNrFHA.3444@.TK2MSFTNGP12.phx.gbl..
.
> You didn't really answer my questions at all, so I'm sorry but I don't hav
e
> any ideas on how to help you.
>
> "Steve Schroeder" <sschroeder@.somewhere.com> wrote in message
> news:u0gIWTNrFHA.2768@.TK2MSFTNGP12.phx.gbl...
>
>
I appreciate the great explanation. Thank you.
"Marina" <someone@.nospam.com> wrote in message news:uQjFnrNrFHA.2880@.TK2MSFT
NGP12.phx.gbl...
Because, who is to say that you always want a postback?
A lot of times, a user is filling out a form, and has many fields to fill ou
t. Then they hit 'Submit', and go to the next page. In this case you would
not want to postback automatically. Not only because there is nothing to do
until the form is filled out, but because it is a waste of resources, and l
ooks ugly with the screen flashing all the time.
So I would say, that it is not the case that people want to postback most of
the time. It really just depends on the type of application and what the UI
needs to do.
I think most people would assume that nothing happens by default, because th
at is what HTML equivalents of these controls would do. And then they add c
ode to change the default behavior.
"Steve Schroeder" <sschroeder@.somewhere.com> wrote in message news:OFaBqoNrF
HA.2624@.TK2MSFTNGP15.phx.gbl...
Well I'll be damned...that worked! Thank you!
For future reference...when would I not want to do a postback, and if 90% of
the time people do postback, why isn't it the default behavior? I would hav
e gnashed my teeth over that one indefinately...
"Marina" <someone@.nospam.com> wrote in message news:O6YP1gNrFHA.528@.TK2MSFTN
GP09.phx.gbl...
Ok, so the problem is that there is no postback to the server!
A server side event can't run, unless something forces a postback to the ser
ver. Your page is sitting in the browser - whatever objects the server used
to generate the page are long gone. HTTP is a connectionless protocol - it'
s just the browser on its own.
So you need something there to trigger an event to the server.
I think the listbox may be one of the objects that has an AutoPostback prope
rty. If it does, setting this to True, will trigger a postback to the server
whenever the selected item is changed.
If the listbox does not have such a property, you need to trigger a postback
. It may be that there is a button the user has to click to proceed, or you
may have to write some javascript to trigger the post.
"Steve Schroeder" <sschroeder@.somewhere.com> wrote in message news:e0RNqcNrF
HA.1128@.TK2MSFTNGP11.phx.gbl...
"How is the user triggering a postback to the server?" - Postback, as I unde
rstand it is triggered by reloading the page. In my case, this is not happen
ing. All the user should be doing is selecting with their mouse and item in
the listbox, and hopefully triggering the OnSelectedIndexChanged event of th
e listbox named lstDepartments.
"What happens when the page posts back to the server? What does it all look
like?" - Nothing happens, the first listbox flickers when you select an item
, and the second listbox remains empty, and no error message occurs.
"Marina" <someone@.nospam.com> wrote in message news:uJuQVWNrFHA.3444@.TK2MSFTNGP12.phx.gbl..
.
> You didn't really answer my questions at all, so I'm sorry but I don't hav
e
> any ideas on how to help you.
>
> "Steve Schroeder" <sschroeder@.somewhere.com> wrote in message
> news:u0gIWTNrFHA.2768@.TK2MSFTNGP12.phx.gbl...
>
>

Triggering ItemCommand with ImageButton in Datagrid

Hi

I had a Delete Column in a datagrid that was a Linkbutton. That needed to
change into a ImageButton because of the design demands in the project. Then
how do I trigger the DeleteCommand with that button?

I don't want to have to add a AddHandler in the ItemCreated or ItemDataBound
for this ImageButton cause then I can't get the ID from the Row to delete as
easy...

please help/
Lars NetzelSpecify the ImageButton with CommandName="Delete" attribute.

<asp:ImageButton ID="btnDelete" runat="server" CommandName="Delete" .../
CommandNames Cancel, Delete, Edit, NextPage, Page, PrevPage, Select, Sort
and Update correspond to the same action with the DataGrid (DataGrid has
these command names predefined for cthese actions)

See docs for further details.

--
Teemu Keiski
ASP.NET MVP, Finland

"Lars Netzel" <uihsdf@.adf.se> wrote in message
news:%23edWRq6LFHA.3328@.TK2MSFTNGP14.phx.gbl...
> Hi
> I had a Delete Column in a datagrid that was a Linkbutton. That needed to
> change into a ImageButton because of the design demands in the project.
> Then how do I trigger the DeleteCommand with that button?
> I don't want to have to add a AddHandler in the ItemCreated or
> ItemDataBound for this ImageButton cause then I can't get the ID from the
> Row to delete as easy...
> please help/
> Lars Netzel
Ah, stupid me:) I wrote ItemCommand instead of CommandName... thx

/Lars

"Teemu Keiski" <joteke@.aspalliance.com> wrote in message
news:eHCfx26LFHA.3988@.tk2msftngp13.phx.gbl...
> Specify the ImageButton with CommandName="Delete" attribute.
> <asp:ImageButton ID="btnDelete" runat="server" CommandName="Delete" .../>
> CommandNames Cancel, Delete, Edit, NextPage, Page, PrevPage, Select, Sort
> and Update correspond to the same action with the DataGrid (DataGrid has
> these command names predefined for cthese actions)
> See docs for further details.
> --
> Teemu Keiski
> ASP.NET MVP, Finland
> "Lars Netzel" <uihsdf@.adf.se> wrote in message
> news:%23edWRq6LFHA.3328@.TK2MSFTNGP14.phx.gbl...
>> Hi
>>
>> I had a Delete Column in a datagrid that was a Linkbutton. That needed to
>> change into a ImageButton because of the design demands in the project.
>> Then how do I trigger the DeleteCommand with that button?
>>
>> I don't want to have to add a AddHandler in the ItemCreated or
>> ItemDataBound for this ImageButton cause then I can't get the ID from the
>> Row to delete as easy...
>>
>> please help/
>> Lars Netzel
>>

Triggering ItemCommand with ImageButton in Datagrid

Hi
I had a Delete Column in a datagrid that was a Linkbutton. That needed to
change into a ImageButton because of the design demands in the project. Then
how do I trigger the DeleteCommand with that button?
I don't want to have to add a AddHandler in the ItemCreated or ItemDataBound
for this ImageButton cause then I can't get the ID from the Row to delete as
easy...
please help/
Lars NetzelSpecify the ImageButton with CommandName="Delete" attribute.
<asp:ImageButton ID="btnDelete" runat="server" CommandName="Delete" .../>
CommandNames Cancel, Delete, Edit, NextPage, Page, PrevPage, Select, Sort
and Update correspond to the same action with the DataGrid (DataGrid has
these command names predefined for cthese actions)
See docs for further details.
Teemu Keiski
ASP.NET MVP, Finland
"Lars Netzel" <uihsdf@.adf.se> wrote in message
news:%23edWRq6LFHA.3328@.TK2MSFTNGP14.phx.gbl...
> Hi
> I had a Delete Column in a datagrid that was a Linkbutton. That needed to
> change into a ImageButton because of the design demands in the project.
> Then how do I trigger the DeleteCommand with that button?
> I don't want to have to add a AddHandler in the ItemCreated or
> ItemDataBound for this ImageButton cause then I can't get the ID from the
> Row to delete as easy...
> please help/
> Lars Netzel
>
Ah, stupid me:) I wrote ItemCommand instead of CommandName... thx
/Lars
"Teemu Keiski" <joteke@.aspalliance.com> wrote in message
news:eHCfx26LFHA.3988@.tk2msftngp13.phx.gbl...
> Specify the ImageButton with CommandName="Delete" attribute.
> <asp:ImageButton ID="btnDelete" runat="server" CommandName="Delete" .../>
> CommandNames Cancel, Delete, Edit, NextPage, Page, PrevPage, Select, Sort
> and Update correspond to the same action with the DataGrid (DataGrid has
> these command names predefined for cthese actions)
> See docs for further details.
> --
> Teemu Keiski
> ASP.NET MVP, Finland
> "Lars Netzel" <uihsdf@.adf.se> wrote in message
> news:%23edWRq6LFHA.3328@.TK2MSFTNGP14.phx.gbl...
>

triggering SQLDATASOURCE insert or update command programatically?

Is there any way to initiate a sqldatasource insert from code in place
of the button with commandname=insert or insert?
I have a formview with a datasource with an insert command on a
button. When the button is selected the insert is performed.
Say I have another button on the form with no command syntax that calls
a some sub. Is there any way to call the same sqldatasource insert
function from code? in debug when I look at the onclick sub that I am
calling when the insert button is pressed, i see all the properties of
the button, like commandname=insert, but that sub is not the real deal
and is infact not even doing anything.
Thanks.Hi,
Have you tried calling the Insert method of the sqldatasource directly, it
should do what you want
Regards,
Mohamed Mosalem
http://mosalem.blogspot.com
"Jason" wrote:

> Is there any way to initiate a sqldatasource insert from code in place
> of the button with commandname=insert or insert?
> I have a formview with a datasource with an insert command on a
> button. When the button is selected the insert is performed.
> Say I have another button on the form with no command syntax that calls
> a some sub. Is there any way to call the same sqldatasource insert
> function from code? in debug when I look at the onclick sub that I am
> calling when the insert button is pressed, i see all the properties of
> the button, like commandname=insert, but that sub is not the real deal
> and is infact not even doing anything.
> Thanks.
>
somebody else suggested that so I tried it, but when I do that for some
reason it does not see bound fields. I had two buttons up, one calling
a sub that did what you suggested and another with no code behind doing
commandname=insert and the only the later would work.
Mohamed Mosalem wrote:
> Hi,
> Have you tried calling the Insert method of the sqldatasource directly, it
> should do what you want
> Regards,
> Mohamed Mosalem
> http://mosalem.blogspot.com
> "Jason" wrote:
>

triggering SQLDATASOURCE insert or update command programatically?

Is there any way to initiate a sqldatasource insert from code in place
of the button with commandname=insert or insert?

I have a formview with a datasource with an insert command on a
button. When the button is selected the insert is performed.

Say I have another button on the form with no command syntax that calls
a some sub. Is there any way to call the same sqldatasource insert
function from code? in debug when I look at the onclick sub that I am
calling when the insert button is pressed, i see all the properties of
the button, like commandname=insert, but that sub is not the real deal
and is infact not even doing anything.

Thanks.Hi,
Have you tried calling the Insert method of the sqldatasource directly, it
should do what you want

Regards,
Mohamed Mosalem
http://mosalem.blogspot.com
"Jason" wrote:

Quote:

Originally Posted by

Is there any way to initiate a sqldatasource insert from code in place
of the button with commandname=insert or insert?
>
I have a formview with a datasource with an insert command on a
button. When the button is selected the insert is performed.
>
Say I have another button on the form with no command syntax that calls
a some sub. Is there any way to call the same sqldatasource insert
function from code? in debug when I look at the onclick sub that I am
calling when the insert button is pressed, i see all the properties of
the button, like commandname=insert, but that sub is not the real deal
and is infact not even doing anything.
>
Thanks.
>
>


somebody else suggested that so I tried it, but when I do that for some
reason it does not see bound fields. I had two buttons up, one calling
a sub that did what you suggested and another with no code behind doing
commandname=insert and the only the later would work.
Mohamed Mosalem wrote:

Quote:

Originally Posted by

Hi,
Have you tried calling the Insert method of the sqldatasource directly, it
should do what you want
>
Regards,
Mohamed Mosalem
http://mosalem.blogspot.com
>
"Jason" wrote:
>

Quote:

Originally Posted by

Is there any way to initiate a sqldatasource insert from code in place
of the button with commandname=insert or insert?

I have a formview with a datasource with an insert command on a
button. When the button is selected the insert is performed.

Say I have another button on the form with no command syntax that calls
a some sub. Is there any way to call the same sqldatasource insert
function from code? in debug when I look at the onclick sub that I am
calling when the insert button is pressed, i see all the properties of
the button, like commandname=insert, but that sub is not the real deal
and is infact not even doing anything.

Thanks.

triggers

I have two tables (STOCK_ITEM and SEASONAL):

STOCK_ITEM
Barcode
Description
Price
Quantity_on_Order
Quantity_in_Stock

SEASONAL
Barcode
Season
Start_Date
End_Date

I want to use a trigger to delete one row out of SEASONAL when one row out
of STOCK_ITEM is deleted. The primary keys of the two rows that are to be
deleted must be the same.

Can you please tell me what is the code for the trigger?

Thanks,

Wally.>> I have two tables (STOCK_ITEM and SEASONAL):...<<

How about using a Cascading Delete...

-- Code
CREATE TABLE StockItems
(
Barcode varchar(20) PRIMARY KEY,
Description varchar(20) NOT NULL,
Price smallmoney NOT NULL,
Quantity_on_Order smallint NULL,
Quantity_in_Stock smallint NOT NULL
);

INSERT StockItems VALUES ('123456789','cool product',11.95,1,10);

CREATE TABLE Seasons
(
SeasonID smallint PRIMARY KEY,
Barcode varchar(20) FOREIGN KEY REFERENCES StockItems(Barcode) ON DELETE
CASCADE,
Season varchar(10) NOT NULL,
Start_Date smalldatetime NOT NULL,
End_Date smalldatetime NOT NULL,
);

INSERT Seasons VALUES (1,'123456789','summer','06/23/06','09/22/06');

DELETE StockItems WHERE Barcode = '123456789';

SELECT COUNT(*) FROM Seasons;

-- results --

0
-- End of Code

Garth
www.SQLBook.com

triggers

I have two tables (STOCK_ITEM and SEASONAL):
STOCK_ITEM
Barcode
Description
Price
Quantity_on_Order
Quantity_in_Stock
SEASONAL
Barcode
Season
Start_Date
End_Date
I want to use a trigger to delete one row out of SEASONAL when one row out
of STOCK_ITEM is deleted. The primary keys of the two rows that are to be
deleted must be the same.
Can you please tell me what is the code for the trigger?
Thanks,
Wally.>> I have two tables (STOCK_ITEM and SEASONAL):...<<
How about using a Cascading Delete...
-- Code
CREATE TABLE StockItems
(
Barcode varchar(20) PRIMARY KEY,
Description varchar(20) NOT NULL,
Price smallmoney NOT NULL,
Quantity_on_Order smallint NULL,
Quantity_in_Stock smallint NOT NULL
);
INSERT StockItems VALUES ('123456789',' product',11.95,1,10);
CREATE TABLE Seasons
(
SeasonID smallint PRIMARY KEY,
Barcode varchar(20) FOREIGN KEY REFERENCES StockItems(Barcode) ON DELETE
CASCADE,
Season varchar(10) NOT NULL,
Start_Date smalldatetime NOT NULL,
End_Date smalldatetime NOT NULL,
);
INSERT Seasons VALUES (1,'123456789','summer','06/23/06','09/22/06');
DELETE StockItems WHERE Barcode = '123456789';
SELECT COUNT(*) FROM Seasons;
-- results --
0
-- End of Code
Garth
www.SQLBook.com