Results 1 to 4 of 4

Thread: [2005] submit form from datagrid

  1. #1

    Thread Starter
    Fanatic Member aconybeare's Avatar
    Join Date
    Oct 2001
    Location
    UK
    Posts
    772

    [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:
    1. <asp:textbox id="txtMS_No" Runat="server" Visible="False"></asp:textbox>
    2. <asp:textbox id="txtUser_Id" Runat="server" Visible="False"></asp:textbox>
    3. <asp:textbox id="txtFull_Name" Runat="server" Visible="False"></asp:textbox>
    4. <asp:textbox id="txtAffiliation" Runat="server" Visible="False"></asp:textbox>
    5. <asp:textbox id="txtAddress" Runat="server" Visible="False"></asp:textbox>
    6. ...
    7. <asp:datagrid id="dgMySubmissions" runat="server" CssClass="DGR_MAIN" AutoGenerateColumns="False">
    8.     <AlternatingItemStyle Cssclass="DGR_ALTERNATE"></AlternatingItemStyle>
    9.     <ItemStyle CssClass="DGR_ITEM"></ItemStyle>
    10.     <HeaderStyle CssClass="DGR_HEADER"></HeaderStyle>
    11.     <Columns>
    12.         <asp:TemplateColumn HeaderText="Date submitted">
    13.             <ItemTemplate>
    14.                 <%# DataBinder.Eval(Container.DataItem, "Submit_Date").ToString()%>
    15.             </ItemTemplate>
    16.         </asp:TemplateColumn>
    17.         <asp:TemplateColumn HeaderText="MS no. (Ver no.)">
    18.             <ItemTemplate>
    19.                 <%#FormatMSNo( _
    20.                      DataBinder.Eval(Container.DataItem, "MS_No").ToString(), _
    21.                      DataBinder.Eval(Container.DataItem, "Version_No"), _
    22.                      ...
    23.                          )%>
    24.             </ItemTemplate>
    25.         </asp:TemplateColumn>
    26.         <asp:TemplateColumn HeaderText="Title">
    27.             <ItemTemplate>
    28.                 <%#FormatTitle( _
    29.                     DataBinder.Eval(Container.DataItem, "MS_No").ToString(), _
    30.                     DataBinder.Eval(Container.DataItem, "Version_No"), _
    31.                     DataBinder.Eval(Container.DataItem, "Title").ToString(), _
    32.                     ...
    33.                 )%>
    34.             </ItemTemplate>
    35.         </asp:TemplateColumn>
    36.         <asp:TemplateColumn HeaderText="Status">
    37.             <ItemTemplate>
    38.                 <%#TranslateStatus( _
    39.                               DataBinder.Eval(Container.DataItem, "Sub_Status").ToString(), _
    40.                               DataBinder.Eval(Container.DataItem, "Status").ToString(), _
    41.                               DataBinder.Eval(Container.DataItem, "MS_No").ToString(), _
    42.                               ...
    43.                                  )%>
    44.             </ItemTemplate>
    45.         </asp:TemplateColumn>
    46.     </Columns>
    47. </asp:datagrid>


    vb Code:
    1. ' Code behind
    2. Public Function TranslateStatus(ByVal sSub_Status As String, _
    3.                 ByVal sStatus As String, _
    4.                 ByVal sMS_No As String, _
    5.                 ...
    6.                 ) As String
    7.  
    8.     Dim sb As New StringBuilder
    9.  
    10.     ...
    11.  
    12.     Select Case sSub_Status.ToUpper
    13.                 ...
    14.         Case "R"
    15.         If sStatus.ToString.ToUpper = "PRD" Then
    16.             ' Any author on the MS can upload print quality files
    17.             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>")
    18.             sb.Append("<br><a href=""https://www.......bj/"" title=""Opt 2 pay"">Opt2Pay</a>")
    19.         End If
    20.     End Select
    21.     Return sb.ToString()
    22. End Function

    Any thoughts or pointers on this will be greatly appreciated

    Cheers Al

  2. #2
    Frenzied Member brin351's Avatar
    Join Date
    Mar 2007
    Location
    Land Down Under
    Posts
    1,293

    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.

  3. #3

    Thread Starter
    Fanatic Member aconybeare's Avatar
    Join Date
    Oct 2001
    Location
    UK
    Posts
    772

    Re: [2005] submit form from datagrid

    Brin,

    Thanks for your reply. Doesn't look like it's going to be easy.

    Cheers Al

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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
  •  



Click Here to Expand Forum to Full Width