Grid View row cell becomes TextBox

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Aug 2007
Posts: 178
Reputation: Kusno is an unknown quantity at this point 
Solved Threads: 14
Kusno's Avatar
Kusno Kusno is offline Offline
Junior Poster

Grid View row cell becomes TextBox

 
1
  #1
May 12th, 2009
Dear all,
I use asp:button field in my gridview

  1. <asp:GridView ID="GV" runat="server" DataSourceID="SDSInHouseRate" Width="100%" AutoGenerateColumns="False" OnRowCommand="GV_RowCommand" OnRowCreated="GV_RowCreated">
  2. <Columns>
  3. <asp:buttonfield buttontype="Button" commandname="edit" text="Edit"/>
  4. <asp:buttonfield buttontype="Button" commandname="approve" text="Approve"/>
  5. <asp:BoundField DataField="Seq" HeaderText="Seq" SortExpression="Seq" />
  6. <asp:BoundField DataField="CurrencyID" HeaderText="CurrencyID" SortExpression="CurrencyID" />
  7. <asp:BoundField DataField="EffectiveDate" HeaderText="Effective Date" SortExpression="EffectiveDate" DataFormatString="{0:yyyy-MM-dd}" HtmlEncode="False" />
  8. <asp:BoundField DataField="Remark" HeaderText="Remark" SortExpression="Remark" />
  9. <asp:BoundField DataField="CreatedBy" HeaderText="CreatedBy" SortExpression="CreatedBy" />
  10. <asp:BoundField DataField="DateCreated" HeaderText="Date Created" SortExpression="DateCreated" DataFormatString="{0:yyyy-MM-dd HH:mm:ss}" HtmlEncode="False"/>
  11. </Columns>
  12. </asp:GridView>

  1. Sub GV_RowCreated(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
  2. If e.Row.RowType = DataControlRowType.DataRow Then
  3. Dim editButton As Button = CType(e.Row.Cells(0).Controls(0), Button)
  4. editButton.CommandArgument = e.Row.RowIndex.ToString()
  5.  
  6. Dim approveButton As Button = CType(e.Row.Cells(1).Controls(0), Button)
  7. approveButton.CommandArgument = e.Row.RowIndex.ToString()
  8. End If
  9. End Sub
  10.  
  11. Sub GV_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
  12. Dim Index As Integer = Convert.ToInt32(e.CommandArgument)
  13. Dim Row As GridViewRow = GVInHouseRate.Rows(Index)
  14. Session("TransMode") = StatusTrans.EditMode
  15. If e.CommandName = "approve" Then
  16. ImgApprover.Disabled = False
  17. CmbCCY.Enabled = False
  18. DTEffectiveDate.Enabled = False
  19. TxtInHouseRate.Enabled = False
  20. TxtRemark.Enabled = False
  21. Else
  22. ButtonReady()
  23. FillData(Val(Row.Cells(2).Text.Trim))
  24. ImgApprover.Disabled = True
  25. End If
  26. 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.
NEVER NEVER NEVER GIVE UP
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 186
Reputation: jbisono is an unknown quantity at this point 
Solved Threads: 24
jbisono's Avatar
jbisono jbisono is offline Offline
Junior Poster

Re: Grid View row cell becomes TextBox

 
0
  #2
May 12th, 2009
I do not really understand your point. because if you want to edit something and that is why you have a edit button, the row you working with should become textbox in order to edit something.
If your already resolved your issue, flag it as solved.
José Bisonó
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 178
Reputation: Kusno is an unknown quantity at this point 
Solved Threads: 14
Kusno's Avatar
Kusno Kusno is offline Offline
Junior Poster

Re: Grid View row cell becomes TextBox

 
0
  #3
May 12th, 2009
I use ButtonField not CommandField.
So, if I click 'Edit', it doesn't mean I want to edit my GridView cell. I want to edit my data in TextBoxes and DropDownList.

But I don't know whether ButtonFeld has the same function with CommandField
NEVER NEVER NEVER GIVE UP
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 37
Reputation: shefeekj has a little shameless behaviour in the past 
Solved Threads: 2
shefeekj shefeekj is offline Offline
Light Poster

Re: Grid View row cell becomes TextBox

 
0
  #4
May 15th, 2009
The command name of the button field might be 'edit' .. just check out
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 37
Reputation: shefeekj has a little shameless behaviour in the past 
Solved Threads: 2
shefeekj shefeekj is offline Offline
Light Poster

Re: Grid View row cell becomes TextBox

 
0
  #5
May 15th, 2009
<asp:buttonfield buttontype="Button" commandname="edit" text="Edit"/>
See this line...The command name of the button field is given as 'edit' which is reserved for performing edit option ..so change the command name .
Last edited by peter_budo; May 15th, 2009 at 7:35 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC