|
-
Feb 7th, 2008, 04:43 AM
#1
Thread Starter
Fanatic Member
[2005] submit form from datagrid
Hi,
I've got a datagrid in which I need to create a link or button to submit a form crosspage passing in a value from the row in the datagrid
Any thoughts on the best way of handling this?
The datagrid holds a list of manuscripts. If the manuscript has been accepted for publication I need to provide a link to the secure payment page (which has been written in classic asp), so need to pass in the manuscript number and other user specific details. I don't want to use the querystring as I don't want users to be able to modify the querystring which is why I want to submit a form
html Code:
<asp:textbox id="txtMS_No" Runat="server" Visible="False"></asp:textbox>
<asp:textbox id="txtUser_Id" Runat="server" Visible="False"></asp:textbox>
<asp:textbox id="txtFull_Name" Runat="server" Visible="False"></asp:textbox>
<asp:textbox id="txtAffiliation" Runat="server" Visible="False"></asp:textbox>
<asp:textbox id="txtAddress" Runat="server" Visible="False"></asp:textbox>
...
<asp:datagrid id="dgMySubmissions" runat="server" CssClass="DGR_MAIN" AutoGenerateColumns="False">
<AlternatingItemStyle Cssclass="DGR_ALTERNATE"></AlternatingItemStyle>
<ItemStyle CssClass="DGR_ITEM"></ItemStyle>
<HeaderStyle CssClass="DGR_HEADER"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="Date submitted">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "Submit_Date").ToString()%>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="MS no. (Ver no.)">
<ItemTemplate>
<%#FormatMSNo( _
DataBinder.Eval(Container.DataItem, "MS_No").ToString(), _
DataBinder.Eval(Container.DataItem, "Version_No"), _
...
)%>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Title">
<ItemTemplate>
<%#FormatTitle( _
DataBinder.Eval(Container.DataItem, "MS_No").ToString(), _
DataBinder.Eval(Container.DataItem, "Version_No"), _
DataBinder.Eval(Container.DataItem, "Title").ToString(), _
...
)%>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Status">
<ItemTemplate>
<%#TranslateStatus( _
DataBinder.Eval(Container.DataItem, "Sub_Status").ToString(), _
DataBinder.Eval(Container.DataItem, "Status").ToString(), _
DataBinder.Eval(Container.DataItem, "MS_No").ToString(), _
...
)%>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
vb Code:
' Code behind
Public Function TranslateStatus(ByVal sSub_Status As String, _
ByVal sStatus As String, _
ByVal sMS_No As String, _
...
) As String
Dim sb As New StringBuilder
...
Select Case sSub_Status.ToUpper
...
Case "R"
If sStatus.ToString.ToUpper = "PRD" Then
' Any author on the MS can upload print quality files
sb.Append("<br><a href=""submission.aspx?page=" & clAct.Encrypt(5) & "&ms_no=" & clAct.Encrypt(sMS_No) & "&ver_no=" & clAct.Encrypt(iVer_No.ToString) & """ title=""Accepted paper upload print quality files"">Upload print quality files</a>")
sb.Append("<br><a href=""https://www.......bj/"" title=""Opt 2 pay"">Opt2Pay</a>")
End If
End Select
Return sb.ToString()
End Function
Any thoughts or pointers on this will be greatly appreciated
Cheers Al
-
Feb 7th, 2008, 06:58 AM
#2
Re: [2005] submit form from datagrid
Your not going to be able to post to another page from a link in a grid. You can set a buttons postBackUrl to what ever page and I guess this will post form data to that non aspx page - but this will be all form data not just one rows textboxes. in clasic asp you could have many forms and repeat them so you could do this - not in asp.net
The HttpWebRequest object will post data to any url but it sits and waits for the response on the sever so you don't go to the url if thats what you need. You can't post from the server to a url and go there because the response will always be to the server.....
What you could do is click the grid link go to a aspx page that you set up with a form in the classic asp style (action=post etc ) without runat=server so you can't use asp.net controls!!!, set hidden fields (not runat=server) value=<%=someValue%> where this is a public variable in code behind so it's accessable in this way. So you've created a clasic asp style form that on submit will post to the url you want. It's a hack that requires the user to make a second step ... you could possibly make javascript submit the form .... good luck
Last edited by brin351; Feb 7th, 2008 at 07:03 AM.
-
Feb 7th, 2008, 07:47 AM
#3
Thread Starter
Fanatic Member
Re: [2005] submit form from datagrid
Brin,
Thanks for your reply. Doesn't look like it's going to be easy.
Cheers Al
-
Feb 7th, 2008, 08:58 AM
#4
Re: [2005] submit form from datagrid
It's just a value from the row in the datagrid. Pass it in the querystring. You don't want to use the querystring because of user interference, so encode it in some simple format.
Another option is to make it an asp linkbutton, handle the ItemCommand event and then do a Response.Write or Server.Transfer, after creating a context variable that contains the ID you want.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|