Dear all,
I use asp:button field in my gridview
<asp:GridView ID="GV" runat="server" DataSourceID="SDSInHouseRate" Width="100%" AutoGenerateColumns="False" OnRowCommand="GV_RowCommand" OnRowCreated="GV_RowCreated">
<Columns>
<asp:buttonfield buttontype="Button" commandname="edit" text="Edit"/>
<asp:buttonfield buttontype="Button" commandname="approve" text="Approve"/>
<asp:BoundField DataField="Seq" HeaderText="Seq" SortExpression="Seq" />
<asp:BoundField DataField="CurrencyID" HeaderText="CurrencyID" SortExpression="CurrencyID" />
<asp:BoundField DataField="EffectiveDate" HeaderText="Effective Date" SortExpression="EffectiveDate" DataFormatString="{0:yyyy-MM-dd}" HtmlEncode="False" />
<asp:BoundField DataField="Remark" HeaderText="Remark" SortExpression="Remark" />
<asp:BoundField DataField="CreatedBy" HeaderText="CreatedBy" SortExpression="CreatedBy" />
<asp:BoundField DataField="DateCreated" HeaderText="Date Created" SortExpression="DateCreated" DataFormatString="{0:yyyy-MM-dd HH:mm:ss}" HtmlEncode="False"/>
</Columns>
</asp:GridView>
Sub GV_RowCreated(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
Dim editButton As Button = CType(e.Row.Cells(0).Controls(0), Button)
editButton.CommandArgument = e.Row.RowIndex.ToString()
Dim approveButton As Button = CType(e.Row.Cells(1).Controls(0), Button)
approveButton.CommandArgument = e.Row.RowIndex.ToString()
End If
End Sub
Sub GV_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
Dim Index As Integer = Convert.ToInt32(e.CommandArgument)
Dim Row As GridViewRow = GVInHouseRate.Rows(Index)
Session("TransMode") = StatusTrans.EditMode
If e.CommandName = "approve" Then
ImgApprover.Disabled = False
CmbCCY.Enabled = False
DTEffectiveDate.Enabled = False
TxtInHouseRate.Enabled = False
TxtRemark.Enabled = False
Else
ButtonReady()
FillData(Val(Row.Cells(2).Text.Trim))
ImgApprover.Disabled = True
End If
End Sub
The problem is, everytime I clicked 'edit' and 'approve' button in gridview, the row cell became TextBox, and can be edited by user also the date became '04/01/2009 12:00:00 AM' difference with the format.
Any suggestion ? please.
Thanks.