Skip to content

ErcanOPAK.com

  • ASP.Net WebForms
  • ASP.Net MVC
  • C#
  • SQL
  • MySQL
  • PHP
  • Devexpress
  • Reportviewer
  • About
ASP.Net WebForms / C#

How to use and get HiddenField Value in Gridview

- 11.06.18 | 14.04.20 - ErcanOPAK

You can add HiddenField to the Gridview like that:

<asp:GridView ID="grdVw" runat="server" AutoGenerateColumns="false">
     <Columns>
         
          <asp:TemplateField>
              <ItemTemplate>
                   <asp:HiddenField ID="hdnID" runat="server" Value='<%# Bind("ID") %>' />
               </ItemTemplate>
           </asp:TemplateField>
     </Columns>
</asp:GridView>

And you can get the HiddenField Value in C# as below:

comboBoxID.SelectedValue = ((HiddenField)grdVw.SelectedRow.Cells[0].FindControl("hdnID").Value;

Related posts:

How to convert JSON to XML or XML to JSON in C#
Change some value inside List
How to apply two classes to a single element in CSS
How to access session variable in App_Code class file?
Post Views: 124

Post navigation

Convert a Comma-Delimited List to a Table in SQL
How to solve “Response.Redirect cannot be called in a Page callback” for DevExpress Components

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

November 2023
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
27282930  
« Oct    

Most Viewed Posts

  • Get the First and Last Word from a String or Sentence in SQL (692)
  • Get the User Name and Domain Name from an Email Address in SQL (690)
  • How to select distinct rows in a datatable in C# (548)
  • Add Constraint to SQL Table to ensure email contains @ (446)
  • Average of all values in a column that are not zero in SQL (366)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (336)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (332)
  • Find numbers with more than two decimal places in SQL (320)
  • Confirm before process with ASPxButton in Devexpress (313)
  • ASPxGridView – Disable CheckBox based on condition in GridViewCommandColumn (288)

Recent Posts

  • How to convert JPG or PNG to WebP in batch or single mode
  • How to get the first and the last day of previous month in SQL Server
  • Not Null check on LEFT function with T-SQL
  • NICE 100 YILLARA TÜRKİYEM
  • How to delete all commit history in github
  • How to display HTML components on the same line in CSS
  • How to insert results of a stored procedure into a temporary table
  • How to remove all non alphanumeric characters from a string in C#
  • How to get the Xth Day of the Week of the Year in C#
  • How to get formatted JSON in C#

Most Viewed Posts

  • Get the First and Last Word from a String or Sentence in SQL (692)
  • Get the User Name and Domain Name from an Email Address in SQL (690)
  • How to select distinct rows in a datatable in C# (548)
  • Add Constraint to SQL Table to ensure email contains @ (446)
  • Average of all values in a column that are not zero in SQL (366)

Recent Posts

  • How to convert JPG or PNG to WebP in batch or single mode
  • How to get the first and the last day of previous month in SQL Server
  • Not Null check on LEFT function with T-SQL
  • NICE 100 YILLARA TÜRKİYEM
  • How to delete all commit history in github

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter

© 2023 ErcanOPAK.com

Proudly powered by WordPress | Theme: Xblog Plus by wpthemespace.com