Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. how to pass gridview textbox value to javascript

how to pass gridview textbox value to javascript

Scheduled Pinned Locked Moved ASP.NET
javajavascripttoolshelptutorial
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    ravihd
    wrote on last edited by
    #1

    Hi I am using gridview in one page and wanted to do some calculation, for this i wanted to pass textbox values to javascript, kindly help me if anyone knows how to pass gridview textbox value to java script. Thanks in advance

    D 1 Reply Last reply
    0
    • R ravihd

      Hi I am using gridview in one page and wanted to do some calculation, for this i wanted to pass textbox values to javascript, kindly help me if anyone knows how to pass gridview textbox value to java script. Thanks in advance

      D Offline
      D Offline
      Dinesh Mani
      wrote on last edited by
      #2

      You can access the grid view's text boxes from javascript by using the controls client id. it will generally be in the patter gridid$controlid$slno. You can get this by viewing the client HTML source on the browser.

      R 1 Reply Last reply
      0
      • D Dinesh Mani

        You can access the grid view's text boxes from javascript by using the controls client id. it will generally be in the patter gridid$controlid$slno. You can get this by viewing the client HTML source on the browser.

        R Offline
        R Offline
        ravihd
        wrote on last edited by
        #3

        is it possible for you to show in example??

        D 1 Reply Last reply
        0
        • R ravihd

          is it possible for you to show in example??

          D Offline
          D Offline
          Dinesh Mani
          wrote on last edited by
          #4

          I don't have access to VS 2005 or greater at work so here is a sample with VS 2003/ASP.NET 1.x - For this datagrid

          		<asp:DataGrid id="DataGrid1" style="Z-INDEX: 102; LEFT: 208px; POSITION: absolute; TOP: 160px"
          			runat="server" AutoGenerateColumns="False">
          			<Columns>
          				<asp:TemplateColumn HeaderText="sd" FooterText="as">
          					<ItemTemplate>
          						<asp:TextBox ID="abc" Runat="server" Text="asd"></asp:TextBox>
          					</ItemTemplate>
          				</asp:TemplateColumn>
          			</Columns>
          		</asp:DataGrid>
          

          and this code

          		DataTable asd = new DataTable("asd");
          		asd.Columns.Add("asd");
          		DataRow dr = asd.NewRow();
          		DataRow dr1 = asd.NewRow();
          		dr\[0\]=asd;
          		dr1\[0\]=asd;
          		asd.Rows.Add(dr);
          		asd.Rows.Add(dr1);
          		DataGrid1.DataSource= asd;
          		DataGrid1.DataBind();
          

          the client ids for the 2 text boxes generated would be DataGrid1__ctl2_abc and DataGrid1__ctl3_abc You can use this id in the getElementById method in javascript to access the data. NOTE - Client id generated in higher version of ASP.NET will be similar but not exactly the same.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups