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>