Link to home
Start Free TrialLog in
Avatar of KaranGupta
KaranGupta

asked on

NewText is not working

Hi

I have a grid view in which I have a commandfield (please check the code section)

My requirement is when I add a new record in the grid the text should be add and when I update the existing row the text should be update. I have tried to use NewText as well. But I am not able to get the desired result.

Am I missing something.

Kindly advice

Regards
Karan Gupta
<asp:CommandField HeaderText = "Edit" EditText = "Edit" CancelText = "Cancel" ShowEditButton = "true" UpdateText = "Update" ControlStyle-CssClass = "LinkButton"/>

Open in new window

Avatar of Mrunal
Mrunal
Flag of India image

Avatar of KaranGupta
KaranGupta

ASKER

Hi

I am not getting the information I need. Could you please tell me where is it.

Regards
Karan Gupta
Hi Karan,
You can not do what you want with CommandField.
CommandField is only for Edit/Delete/Update/Cancel.

For adding new record you can add another button.

Hi

I think I was not able to elaborate the question well. I don't want functionality but what I want is when the user adds new record in the gridview then text of update Link should be "Add" and if updating the existing record then it should be "update". Please let me know in case of any other information.

Regards
Karan Gupta
The GridView does not have feature to add records using New button. You need to use DetailsView to have a form to add records and display it in GridView.
If you want to display 'New' button, you need to use CommandField.ShowInsertButton Property.  But this property applies only to data-bound controls that support insert operations, such as the DetailsView control.
Try the following examples
Detailsview: insert / update single record
http://www.devx.com/dotnet/Article/22141/0/page/4
Inserting new row in GridView in ASP.NET 2.0
GridView extras - DetailsView
Hi

I just want to rename update button at run time. Is that possible.

Regards
Karan
try at OnRowDataBound event, access that button / link and assign new text value.
How can we access that
ASKER CERTIFIED SOLUTION
Avatar of Mrunal
Mrunal
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial