473,698 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

response redirect without asking

I have a datagrid with update/cancel on one side, a button on the
other which, when clicked, will take the user to a page that allows
them to e-mail that particular observation's data. My problem, is
that I have some columns that are sortable. To make everything work,
I can wrap the e-mail code in a 'if not.postback' statement (wrong I
know--testing here), but then, my sorts/updates/cancels don't work
because an error is thrown from the page I redirect to . . . even
though I haven't pressed the e-mail button. For example, for the code
I post below, if I sort a row, an error is thrown from code within the
sendmail.aspx page. I don't understand this and can't step through it
(using Dreamweaver).

I'm sure I'm doing something really silly. Any help is appreciated.

<%@ Page Language="VB" ContentType="te xt/html"
ResponseEncodin g="iso-8859-1" %>
<%@ Import Namespace="Syst em.Data" %>
<%@ Import Namespace="Syst em.Data.SQLClie nt" %>
<%@ Import Namespace="Syst em.Web.Mail" %>
<script language="VB" runat="server">
Sub MyDataGrid_Edit Command(s As Object, e As DataGridCommand EventArgs
)
MyDataGrid.Edit ItemIndex = e.Item.ItemInde x
BindData("zyp9. Outbreak.DtRpt DESC")
End Sub

Sub MyDataGrid_Canc el(Source As Object, E As DataGridCommand EventArgs)
MyDataGrid.Edit ItemIndex = -1
BindData("zyp9. Outbreak.DtRpt DESC")
End Sub

Sub Page_Load(Sourc e as Object, E as EventArgs)
if not Page.IsPostBack then
BindData("zyp9. Outbreak.DtRpt DESC")
end if
End Sub

Sub Page_Change(sen der As Object, e As DataGridPageCha ngedEventArgs)
MyDataGrid.Curr entPageIndex = e.NewPageIndex
BindData("zyp9. Outbreak.DtRpt DESC")
End Sub

Sub BindData( strSortField as String )
Dim strConn as string =
"server=DEV1;ui d=user;pwd=xxx; database=OUTBRE AK"
Dim sql as string = "SELECT zyp9.Outbreak.R owId,
zyp9.Outbreak.T itle, zyp9.Outbreak.S tate, zyp9.Outbreak.S ts_Af, " & _
"zyp9.Outbreak. DtRpt, zyp9.Outbreak.D isease,
zyp9.Outbreak.T ype, zyp9.Outbreak.C ases, " & _
"zyp9.Outbreak. Alias, zyp9.Email.lnam e + ', ' +
zyp9.Email.fnam e as Name " & _
"FROM zyp9.Outbreak, zyp9.email " & _
"WHERE (zyp9.Outbreak. alias=zyp9.Emai l.alias) " & _
"ORDER BY " & strSortField
Dim conn as New SQLConnection(s trConn)
Dim objDR as SQLDataReader
Dim Cmd as New SQLCommand(sql, conn)
conn.Open()
objDR=Cmd.Execu teReader(system .data.CommandBe havior.CloseCon nection)
MyDataGrid.Data Source = objDR
MyDataGrid.Data Bind()
conn.close
End Sub

Sub dgSort( s As object, e as DataGridSortCom mandEventArgs)
BindData (e.SortExpressi on)
End Sub

Sub MyDataGrid_Upda teCommand(s As Object, e As
DataGridCommand EventArgs )
Dim conn As SqlConnection
Dim Cmd As SqlCommand
Dim strConn as string =
"server=DEV1;ui d=user;pwd=xxx; database=OUTBRE AK"
Dim txtTitle As textbox = E.Item.cells(2) .Controls(0)
Dim txtState As textbox = E.Item.cells(3) .Controls(0)
Dim txtSts_Af As textbox = E.Item.cells(4) .Controls(0)
Dim txtDtRpt As textbox = E.Item.cells(5) .Controls(0)
Dim txtDisease As textbox = E.Item.cells(6) .Controls(0)
Dim txtType As textbox = E.Item.cells(7) .Controls(0)
Dim txtCases As textbox = E.Item.cells(8) .Controls(0)
Dim strUpdateStmt As String
strUpdateStmt ="UPDATE zyp9.Outbreak SET Title =@Title, State
=@State, Sts_Af =@Sts_Af, " & _
"DtRpt =@DtRpt, Disease=@Diseas e, Type=@Type,
Cases=@Cases " & _
"WHERE RowId = @RowId"
conn = New SqlConnection(s trConn)
Cmd = New SqlCommand(strU pdateStmt, conn)
Cmd.Parameters. Add(New SQLParameter("@ Title", txtTitle.text))
Cmd.Parameters. Add(New SQLParameter("@ State", txtState.text))
Cmd.Parameters. Add(New SQLParameter("@ Sts_Af", txtSts_Af.text) )
Cmd.Parameters. Add(New SQLParameter("@ DtRpt", txtDtRpt.text))
Cmd.Parameters. Add(New SQLParameter("@ Disease", txtDisease.text ))
Cmd.Parameters. Add(New SQLParameter("@ Type", txtType.text))
Cmd.Parameters. Add(New SQLParameter("@ Cases", txtCases.text))
Cmd.Parameters. Add(New SQLParameter("@ RowID", e.Item.Cells(1) .Text))
conn.Open()
Cmd.ExecuteNonQ uery()
MyDataGrid.Edit ItemIndex = -1
conn.close
BindData("zyp9. Outbreak.RptDt DESC")
End Sub

Sub Email_Report(s As Object, e As DataGridCommand EventArgs)
Dim strRowID As string = E.Item.cells(1) .text
Dim strAlias as string = E.Item.cells(10 ).text

'If Not Page.IsPostBack Then
e.Item.Backcolo r = system.drawing. color.lightgree n
e.item.font.bol d = true
Response.Redire ct("SendMail.as px?RowId=" &
System.Web.Http Utility.UrlEnco de(strRowId) _
& "&Alias=" &
System.Web.Http Utility.UrlEnco de(strAlias))
'End If
End Sub
</script>

<html>
<head>
<title>Entry Edit</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<body>
<table width="263" border="1" align="center" id="nav_bar">
<tr>
<td height="22" colspan="2">
<div align="center">
<font color="#333366" size="3" face="Geneva, Arial, Helvetica,
sans-serif">
<strong>Outbrea k Entry Report</strong>
</font>
</div>
</td>
</tr>
<tr>
<td width="122">
<div align="center">
<font color="#333366" size="3" face="Geneva, Arial, Helvetica,
sans-serif">
<strong>
<a href="http://acid-xdv-webdv1/hepatitis/default.htm">Ho me</a>
</strong>
</font>
</div>
</td>
<td width="125">
<div align="center"> <font color="#333366" size="3" face="Geneva,
Arial, Helvetica, sans-serif">
<strong><a href="http://acid-xdv-webdv1/hepatitis/default.htm">Xy z</a></strong>
</font> </div>
</td>
</tr>
</table>
<hr>
<form name="form1" method="post" runat="server">
<asp:Datagrid runat="server"
Id="MyDataGrid "
GridLines="Both "
cellpadding="2"
cellspacing="2"
Headerstyle-BackColor="#808 0C0"
Headerstyle-Font-Name="Arial"
Headerstyle-Font-Size="12"
Headerstyle-Font-Bold="True"
AutogenerateCol umns="False"
OnEditcommand=" MyDataGrid_Edit Command"
OnCancelcommand ="MyDataGrid_Ca ncel"
OnUpdateCommand ="MyDataGrid_Up dateCommand"
OnItemCommand=" Email_Report"
OnPageIndexChan ged="Page_Chang e"
AllowSorting = "True"
OnSortCommand ="dgSort"
DataKeyField="R owId">
<ItemStyle BackColor="#F2F 2F2" Font-Name="Verdana, Arial,
Helvetica, sans-serif" Font-Size="smaller" />
<AlternatingIte mStyle BackColor="#E5E 5E5"
Font-Name="Verdana, Arial, Helvetica,
sans-serif"
Font-Size="smaller" />
<Columns>
<asp:EditComman dColumn
ButtonType="Lin kButton"
UpdateText="Upd ate"
CancelText="Can cel"
EditText="<IMG SRC='pics/Edit.gif' Border=0 Width=12 Height=12>"
ItemStyle-HorizontalAlign ="Center"
HeaderText="Edi t">
</asp:EditCommand Column>
<asp:BoundColum n
DataField="RowI d"
HeaderText="ID"
ReadOnly="True"
SortExpression= "zyp9.Outbreak. RowId">
</asp:BoundColumn >
<asp:BoundColum n
DataField="Titl e"
HeaderText="Tit le">
</asp:BoundColumn >
<asp:BoundColum n
DataField="Stat e"
HeaderText="Sta te">
</asp:BoundColumn >
<asp:BoundColum n
DataField="Sts_ Af"
HeaderText="Oth er States">
</asp:BoundColumn >
<asp:BoundColum n
DataField="DtRp t"
HeaderText="Dat e Rptd"
DataFormatStrin g="{0:d}"
SortExpression= "zyp9.Outbreak. DtRpt DESC">
</asp:BoundColumn >
<asp:BoundColum n
DataField="Dise ase"
HeaderText="Dis ease">
</asp:BoundColumn >
<asp:BoundColum n
DataField="Type "
HeaderText="Typ e">
</asp:BoundColumn >
<asp:BoundColum n
DataField="Case s"
HeaderText="Cas es">
</asp:BoundColumn >
<asp:BoundColum n
DataField="Name "
HeaderText="Rec ipient"
ReadOnly="True"
SortExpression= "zyp9.Email.LNa me">
</asp:BoundColumn >
<asp:BoundColum n
DataField="Alia s"
HeaderText="Ali as"
ReadOnly="True" >
</asp:BoundColumn >
<asp:ButtonColu mn
Text="<IMG SRC='pics/email05a.gif' Border=0 Width=20
Height=20>"
ItemStyle-HorizontalAlign ="Center"
HeaderText="E-Mail"
CommandName="Em ail">
</asp:ButtonColum n>
</Columns>
</asp:DataGrid>
</form>
</body>
</html>
Nov 17 '05 #1
0 2477

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1976
by: Bill | last post by:
I've got an application that I want to redirect to another file while keeping the location of the file hidden. In other words, WEBROOT.COM/REDIT.ASP?a=14 is going to display the contents of file WEBROOT.COM/SECURE12954 without the user knowing they are in the /SECURE12954 subdir.
11
9940
by: Peter D | last post by:
I wanted to add this method to my .asp page in order to dynamically choose a page based upon some selection criteria. It's in my .asp book and in the online reference. Yet when I use this object, the following error returns in the browser: Error Type: Microsoft VBScript runtime (0x800A01B6) Object doesn't support this property or method: 'Response.Redirect' /testwebs/choose.asp, line 22
6
1933
by: dotnettester | last post by:
Woud this work? ..... Response.end set objConn = nothing set objAnyObject = nothing ?
3
9075
by: Justin | last post by:
Hi, Im confused here over the usage of Response.Redirect and Server.Transfer. I used frameset for my work, what are the proper usages of the two methods that seems working similar.. The problem i faced while using Response.Redirect is that the page that is directed to, does not looks as desired..the textboxes are not visible anymore and so as
3
2621
by: Grant | last post by:
What is the difference between server.transfer(page.aspx) and redirect.response(page.aspx)? Some of the users get a blank page if I use redirect.response. I changed it to server.transfer because it works but what is the difference? Thanks
6
2905
by: Keith Patrick | last post by:
I have to do some programmatic redirects (in several pages) based on URLs I am given from an external source. The URLs have querystrings at the end, but one in particular is about 240 chars long, so I need to programmatically redirect to it. Unfortunately, I can't find a way to do it. There is no Response.Form or Response.Attributes (Request has Form and Params, but they are read-only). I've tried using AppendHeader to pass my K/V pairs...
12
1491
by: gigi | last post by:
How to send more than one value using response redirect? For example i can send one like this response.Redirect "pregled.asp?ime=" & strUserName but how to send two or more values? I tried response.Redirect("pregled.asp?ime=" & strUserName & " & prezime = " & strUserLastName) but it didn't work.
9
4343
by: RN1 | last post by:
When a server encounters the line Response.Redirect("abcd.asp") in a ASP script, the server tells the browser that it has to be redirected to another page (which is abcd.asp, in this case). The browser then makes a new request to the server to redirect itself to abcd.asp after which the user gets redirected to abcd.asp. But in case of Server.Execute (or Server.Transfer), when the server
2
3374
by: daveh551 | last post by:
Okay, I asked a question a week or so ago asking for an explanation on relative URL's and the "~" symbol, and several people explained that the "~" is only usable when the URL is going to be parsed by ASP.NET. I have a TreeView control with a hierarchical Category listing of products. Here is the code in selected node changed event: protected void CategoryTreeView_SelectedNodeChanged(object sender, EventArgs e) {
0
8674
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9026
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4366
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.