Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 3rd, 2005, 08:27 AM
Friend of Wrox
 
Join Date: Mar 2005
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to pass hideen value using link button?

How to link the last two buttons called delete and penalites to another page and pass them playerno value ?
some thing similer to this one :

<td><td><a href = "playerprofile.aspx?person_id=<%#Container.DataIte m("playerno")%>"><%#Container.DataItem("playerno") %></a></td>

currenly the two buttons does not do much when they are click click. i want them to pass palayerno value to a a new page called for example secondpage.aspx
I be happy if some one help me fix those two buttons to do the right thing.Thanks
Here is my code:

<asp:DataGrid id="DBEditDataGrid" runat="server"
    BorderWidth = "1" CellSpacing = "2" CellPadding = "2"
    HeaderStyle-Font-Bold = "True"

     OnEditCommand = "DBEditDataGrid_Edit"
    OnCancelCommand = "DBEditDataGrid_Cancel"
    OnUpdateCommand = "DBEditDataGrid_Update"

    AutoGenerateColumns = "False"
>
    <Columns>

        <asp:BoundColumn HeaderText="PLAYERNO" DataField="PLAYERNO" ReadOnly="True" />
        <asp:BoundColumn HeaderText="NAME" DataField="NAME" />
        <asp:BoundColumn HeaderText="INITIALS" DataField="INITIALS" />
        <asp:BoundColumn HeaderText="BIRTH_DATE" DataField="BIRTH_DATE" />
                <asp:BoundColumn HeaderText="************" DataField="************" />
                <asp:BoundColumn HeaderText="JOINED" DataField="JOINED" />
                <asp:BoundColumn HeaderText="STREET" DataField="STREET" />
                <asp:BoundColumn HeaderText="HOUSENO" DataField="HOUSENO" />
                <asp:BoundColumn HeaderText="POSTCODE" DataField="POSTCODE" />
                <asp:BoundColumn HeaderText="TOWN" DataField="TOWN" />
                <asp:BoundColumn HeaderText="PHONENO" DataField="PHONENO" />
                <asp:BoundColumn HeaderText="LEAGUENO" DataField="LEAGUENO" />

        <asp:EditCommandColumn
            HeaderText = "Edit"
            EditText = "Edit"
            CancelText = "Cancel"
            UpdateText = "Update"
        />

                <asp:EditCommandColumn
            ButtonType="LinkButton"
            UpdateText="Update"
            CancelText="Cancel"
            EditText="<IMG SRC=/images/Edit.gif Border=0 Width=12 Height=12>"
                                                ItemStyle-HorizontalAlign="Center"
                        HeaderText="Delete">
        </asp:EditCommandColumn>
                 <asp:EditCommandColumn
            ButtonType="LinkButton"
            UpdateText="Update"
            CancelText="Cancel"
            EditText="<IMG SRC=/images/Edit.gif Border=0 Width=12 Height=12>"
                                                ItemStyle-HorizontalAlign="Center"
                        HeaderText="Penalties">
        </asp:EditCommandColumn>
    </Columns>
</asp:DataGrid>
 
Old May 3rd, 2005, 10:31 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Change the page in the HREF to the page you want to receive the information. Then that page can check the querystring values for the player number.

-Peter
 
Old May 3rd, 2005, 10:37 AM
Friend of Wrox
 
Join Date: Mar 2005
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by planoie
 Change the page in the HREF to the page you want to receive the information. Then that page can check the querystring values for the player number.

-Peter
what is href ?

 
Old May 3rd, 2005, 11:11 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

In your <a> tag. Change "playerprofile.aspx" to the page you want to go to: "secondpage.aspx".

<td><td><a href = "secondpage.aspx?person_id=<%#Container.DataItem(" playerno")%>"><%#Container.DataItem("playerno")%></a></td>


-Peter
 
Old May 3rd, 2005, 11:22 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Ok. After another look, I understand what you are trying to do. If you want to use the datagrid button column to go to the other page, you'll need to use the "DeleteCommand" and "ItemCommand" datagrid event. Then you can use Response.Redirect() to redirect to the page that serves these functions. Alternatively you could use a hyperlink column in the grid to serve as a direct link to those pages and use the format properties of the HyperLinkColumn markup to construct the appropriate URLs.

http://msdn.microsoft.com/library/de...classtopic.asp


I think the problem here is that you don't have a clear understanding of what the EditCommandColumn is for. That column is designed to provide you the means to switch 1 entire row into edit mode. It's not intended to provide editing for one *column* of one row but for the entire row. If you want to be able to edit the penalties for a player (the player represented in 1 row) you could use the EditCommandColumn to turn on editing for that row and include the penalties column in the grid. Then you can edit the penalties and save the results back to the database. You could make all columns except the penalties column read-only so that you essentially end up with a single edit column.

-Peter
 
Old May 3rd, 2005, 04:16 PM
Friend of Wrox
 
Join Date: Mar 2005
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default

many thanks to u planoie . I will try to follow your suggestions. I got this asp.net begining with vb.net but it never teaches me these things. could u suggest any other book or articles.Thanks

 
Old May 4th, 2005, 07:51 AM
Friend of Wrox
 
Join Date: Mar 2005
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by planoie
 Ok. After another look, I understand what you are trying to do. If you want to use the datagrid button column to go to the other page, you'll need to use the "DeleteCommand" and "ItemCommand" datagrid event. Then you can use Response.Redirect() to redirect to the page that serves these functions. Alternatively you could use a hyperlink column in the grid to serve as a direct link to those pages and use the format properties of the HyperLinkColumn markup to construct the appropriate URLs.

http://msdn.microsoft.com/library/de...classtopic.asp


I think the problem here is that you don't have a clear understanding of what the EditCommandColumn is for. That column is designed to provide you the means to switch 1 entire row into edit mode. It's not intended to provide editing for one *column* of one row but for the entire row. If you want to be able to edit the penalties for a player (the player represented in 1 row) you could use the EditCommandColumn to turn on editing for that row and include the penalties column in the grid. Then you can edit the penalties and save the results back to the database. You could make all columns except the penalties column read-only so that you essentially end up with a single edit column.

-Peter
Many thanks to u reply. After reading your reply i decided to use hyperlinkcolumn buttons.

My problem is how to create HyperLinkColumn buttons that holds "playerno" value for each record row in my player table !
i want the HyperLinkColumn button to pass the "playerno" value to a new poped up page so that i use it
(playerno value) to edit a diffrent table row such as penalty table coresponded to that playerno value record.

In another word,i want to jump directly to edit mode(by clicking the penalty HyperLinkColumn button) for entire
penalty table row that has the following columns paymentno,playerno,pay_date and amount(in the new poped up page).

Note :i lookd at the example in the linked that u posted .that hyperlinkcolumn button passes integer value 0-2 .
But i want pass playerno value that exists in player table.But i do not know how to retrive that and place
it in : DataNavigateUrlFormatString="detailspage.aspx?id={ 0}" instad of value 0

************************************************** *********************
Note: In creating the hyperlinkcolumn buttons I want to keep the part below.which enables me to
switch to edit mode for each record row of player table in my db. This part is doing the correct
thing and i want to keep it like that.:

 <asp:DataGrid id="DBEditDataGrid" runat="server"
    BorderWidth = "1" CellSpacing = "2" CellPadding = "2"
    HeaderStyle-Font-Bold = "True"

     OnEditCommand = "DBEditDataGrid_Edit"
    OnCancelCommand = "DBEditDataGrid_Cancel"
    OnUpdateCommand = "DBEditDataGrid_Update"

    AutoGenerateColumns = "False"
>
    <Columns>

        <asp:BoundColumn HeaderText="PLAYERNO" DataField="PLAYERNO" ReadOnly="True" />
        <asp:BoundColumn HeaderText="NAME" DataField="NAME" />
        <asp:BoundColumn HeaderText="INITIALS" DataField="INITIALS" />
        <asp:BoundColumn HeaderText="BIRTH_DATE" DataField="BIRTH_DATE" />
                <asp:BoundColumn HeaderText="************" DataField="************" />
                <asp:BoundColumn HeaderText="JOINED" DataField="JOINED" />
                <asp:BoundColumn HeaderText="STREET" DataField="STREET" />
                <asp:BoundColumn HeaderText="HOUSENO" DataField="HOUSENO" />
                <asp:BoundColumn HeaderText="POSTCODE" DataField="POSTCODE" />
                <asp:BoundColumn HeaderText="TOWN" DataField="TOWN" />
                <asp:BoundColumn HeaderText="PHONENO" DataField="PHONENO" />
                <asp:BoundColumn HeaderText="LEAGUENO" DataField="LEAGUENO" />

        <asp:EditCommandColumn
            HeaderText = "Edit"
            EditText = "Edit"
            CancelText = "Cancel"
            UpdateText = "Update"
        />


    </Columns>
</asp:DataGrid>


************************************************** **********************


 Help needed in :

1) construct HyperLinkColum button for each record row in my player table just next to edit button. (in the first page)
2) after clicking on the HyperLinkColum button(in first page) i jump directly to edit mode coresponding to playerno value in
   pentaity table(in new page). (constructing the new page to show the penalty row in edit mode)

Thanks and looking forward to your reply.

--------------------------------------------------------------------------------------------------------------------

Player table:

PLAERNO,NAME,INITIALS,BIRH_DATE,************,JOINED,SREET,H OUSENO,POSTCODE,TOWN,PHONENO,LEAGUENO


Penalties table:
PAYEMENTNO,PLAYERNO,PEN_DATE,AMOUNT

--------------------------------------------------------------------------------------------------------------------------
HyperLinkColumn code:

<%@ Page Language="VB" AutoEventWireup="True" %>
<%@ Import Namespace="System.Data" %>

<html>

<head>

   <script runat="server">

      Function CreateDataSource() As ICollection

         Dim dt As DataTable = New DataTable()
         Dim dr As DataRow
         Dim i As Integer

         dt.Columns.Add(New DataColumn("IntegerValue", GetType(Int32)))
         dt.Columns.Add(New DataColumn("PriceValue", GetType(Double)))

         For i = 0 to 2

            dr = dt.NewRow()

            dr(0) = i
            dr(1) = CDbl(i) * 1.23

            dt.Rows.Add(dr)

         Next i

         Dim dv As DataView = New DataView(dt)
         Return dv

      End Function

      Sub Page_Load(sender As Object, e As EventArgs)

         MyDataGrid.DataSource = CreateDataSource()
         MyDataGrid.DataBind()

      End Sub

   </script>

</head>

<body>

   <form runat="server">

      <h3>HyperLinkColumn Example<h3>

      <asp:DataGrid id="MyDataGrid"
           BorderColor="black"
           BorderWidth="1"
           GridLines="Both"
           AutoGenerateColumns="false"
           runat="server">

         <HeaderStyle BackColor="#aaaadd"/>

         <Columns>

            <asp:HyperLinkColumn
                 HeaderText="Select an Item"
                 DataNavigateUrlField="IntegerValue"
                 DataNavigateUrlFormatString="detailspage.aspx?id={ 0}"
                 DataTextField="PriceValue"
                 DataTextFormatString="{0:c}"
                 Target="_blank"/>

         </Columns>

      </asp:DataGrid>

   </form>

</body>
</html>

 
Old May 4th, 2005, 08:13 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

method,

That MSDN article has everything you need to complete your task. Did you read the whole article?

You use DataTextFormatString to specify the format of the hyperlink text and the DataNavigateUrlFormatString to specify the format of the URL. You use the corresponding properties DataTextField and DataNavigateUrlField to set the datafield from which to pull the data that gets placed in the hyperlink text and url respectively. If you don't need to format the output, you can omit the property and the data won't be formatted.

<asp:HyperLinkColumn HeaderText="Penalties" Target="_blank"
  DataNavigateUrlField="playerno" DataNavigateUrlFormatString="secondpage.aspx?perso n_id={0}"
  DataTextField="playerno" />

Instead of making the link be the player number, you could also have a static link text that appears for all players:

<asp:HyperLinkColumn HeaderText="Penalties" Target="_blank"
  DataNavigateUrlField="playerno" DataNavigateUrlFormatString="secondpage.aspx?perso n_id={0}"
  Text="Click Me" />

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
Link Button deontae45 ASP.NET 1.0 and 1.1 Basics 2 June 23rd, 2007 04:46 PM
Link Button sohrabus ASP.NET 2.0 Professional 1 November 14th, 2006 08:33 AM
Link Button sohrabus ASP.NET 1.0 and 1.1 Professional 3 October 27th, 2006 07:08 AM
Pass a parameter in a link jmss66 Classic ASP Basics 1 October 20th, 2006 02:23 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.