943,662 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Marked Solved
  • Views: 4381
  • ASP.NET RSS
May 12th, 2009
1

Grid View row cell becomes TextBox

Expand Post »
Dear all,
I use asp:button field in my gridview

ASP.NET Syntax (Toggle Plain Text)
  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>

ASP.NET Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 11
Solved Threads: 17
Junior Poster
Kusno is offline Offline
191 posts
since Aug 2007
May 12th, 2009
0

Re: Grid View row cell becomes TextBox

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.
Reputation Points: 56
Solved Threads: 56
Posting Pro in Training
jbisono is offline Offline
432 posts
since May 2009
May 12th, 2009
0

Re: Grid View row cell becomes TextBox

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
Reputation Points: 11
Solved Threads: 17
Junior Poster
Kusno is offline Offline
191 posts
since Aug 2007
May 15th, 2009
0

Re: Grid View row cell becomes TextBox

The command name of the button field might be 'edit' .. just check out
Reputation Points: 1
Solved Threads: 2
Light Poster
shefeekj is offline Offline
37 posts
since Apr 2009
May 15th, 2009
0

Re: Grid View row cell becomes TextBox

<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.
Reputation Points: 1
Solved Threads: 2
Light Poster
shefeekj is offline Offline
37 posts
since Apr 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: looking for good sites
Next Thread in ASP.NET Forum Timeline: get row values from gridview when checkbox selected





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC