RedRocket
RedRocket

Reputation: 1733

How to show data in gridview without textbox

I am creating a gridview in a web form application. I have provided the link below for reference. In this gridview, I have textboxes in each row and when I click save, it can save the data to database. However, the gridview itself still have the textboxes in each row after I click saved. My question is how can I not show the textboxes when I click the save button but instead only show the text that I have entered in each row? Help will be appreciated.

Here is the link that I use for my gridview

http://www.aspsnippets.com/Articles/Save-and-Retrieve-Dynamic-TextBox-values-in-GridView-to-SQL-Server-Database.aspx

Upvotes: 0

Views: 705

Answers (2)

Vivek Verma
Vivek Verma

Reputation: 333

In the markup of your page add a label to each itemtemplate column and set the visible property to false, like this:

<ItemTemplate>
   <asp:TextBox ID="TextBox1" runat="server" Visible="true"></asp:TextBox>    
   <asp:Label ID="Label1" runat="server" Visible="false"></asp:Label>
</ItemTemplate>

Then use FindControl like you are doing with the textboxes and set visible for the textboxes to false and visible for the labels to true in the click event of the Save button.

Upvotes: 1

Kutty Rajesh Valangai
Kutty Rajesh Valangai

Reputation: 635

Use this Example below,for gridview CRUD opeartion with Editable textbox in columns,

www.c-sharpcorner.com/uploadfile/raj1979/select-add-update-and-delete-data-in-a-Asp-Net-gridview-control/

Upvotes: 1

Related Questions