Problem getting an input value from a textbox in a GridView control

I placed a text box in one of my template columns in a gridview control:

<Columns>
                <asp:CommandField ShowEditButton="True" />
                <asp:TemplateField><ItemTemplate><asp:TextBox runat=server ID="TextBox" Width="30"></asp:TextBox></ItemTemplate></asp:TemplateField>
 </Columns>

Upon opening a page, my gridview is set up to be populated with data  from a datasource, so the number of rows may increase as the database gets larger.  I am trying to allow users to type in a value into the textbox, and this value will be written to a different table in the database.  I tried to use this code technique to retrieve the value typed into the textbox:

Dim dgi As GridViewRow
        Dim ds As DataSet = Session("Dataset1")
        For Each dgi In GridView1.Rows
            Dim score As String = CType(dgi.FindControl("TextBox"), TextBox).Text
            ListBox1.Items.Add(score)
        Next

However, as I debug after putting phoney value in each text box in the control, and go through each line in the code, the value is not being grabbed.  As it goes through,  the  debugger states that  "Dim score="" " .  I typed in numbers, but the strings are coming up empty.  Can someone help?  Is it my code?  I've been on the internet and from what I read this is the correct syntax, so I don't know why the string is empty. 

Anyone?
0
Juwar
5/24/2007 11:04:52 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

1 Replies
746 Views

Similar Articles

[PageSpeed] 57

Hi:

  First, please check whether you've set EnableViewState="false". If you did, set EnableViewState="true".

  If it still doesn't work, please post your aspx for us to reproduce your scenario.

Thanks


Sincerely,
Allen Chen
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Allen
5/28/2007 6:23:48 AM
Reply:

Similar Artilces:

Problem getting input value from a textbox in a Gridview Control
I placed a text box in one of my template columns in a gridview control:<Columns>                <asp:CommandField ShowEditButton="True" />                <asp:TemplateField><ItemTemplate><asp:TextBox runat=server ID="TextBox" Width="30"></asp:TextBox></ItemTemplate></asp:TemplateField> </Columns>Upon opening a page, my gridview is set up to be populate...

using javascript getting value from textbox when edit button is clicked and both controls are present in gridview control
Hi All using javascript I want to get value  from textbox when edit button is clicked and both controls that is texbox and button are present in gridview control .Alok Hi aloksinha83, Please see this post: http://forums.asp.net/t/1069245.aspx Thanks,Qin Dian TangMicrosoft Online Community SupportPlease remember to mark the replies as answers if they help and unmark them if they provide no help....

Getting the control id of a control inside gridview control
 uhmm.. a little bit confusing regarding my subject because i dont know how to say it...by the way my problem is how can i get the id of a control (e.g. textbox) inside the gridview... and the textbox is in the templatefield... is there any way i can get its id??  hoping i could get a reply as soon as possible... Regards,MhaeyPlease remember to click “Mark as Answer” on the post that helps you.. =) What do you want's to do by getting the id of the Text box? Do you want's to find particular Textbox with certain id ? Kamran ShahidSr. Software Engineer(MCP,MCAD.net,MC...

How to add values to template control fields textbox control in GridView..
Hi all,    <asp:GridView ID="GridView1" EnableViewState="true" DataKeyNames="LicenseTemplateID"                       runat="server" AutoGenerateColumns="False" OnSelectedIndexChanged="GridView1_SelectedIndexChanged"                       Width="345px">                       <Columns>                           <asp:Templa...

Get controlID from control (textbox) inside another control (gridview)
Ok, so I've been trying to get a link within the edit item template of a gridview to open a new window.  I can do that fine, but when I try to pass the new window the controlID of the textbox to pass the value back to in the originating page I can't get the correct ID.  (that was a mouthful)  Maybe my code will explain better...  <EditItemTemplate> <asp:TextBox ID="EndTextBox" runat="server" Text='<%# Bind("endtime") %>'></asp:TextBox> <a href="javascript:;" onclick="window.open...

Get value from Gridview into textbox and dropDrownList controls
  Hi to all,I (newbie) want that when user click on ID field of Gridview.The values of that particular ID row should display in the textbox and dropdown list of the page.<asp:Label ID="lblAccessID" runat="server" Text="Access ID" Width="91px" Height="16px"></asp:Label>        <asp:TextBox ID="txtAccessID" runat="server" Height="12px" Width="126px"></asp:TextBox> <br /><br />        &l...

Cannot get value from an input textbox to a listbox web control??
I am about to go nuts because I really have not done any Asp.Net programming up until now. I have mainly done desktop applications. I am trying to take the textbox in the page and pass the contents of it to the listbox on the same page. I cannot get the values from the textbox to the listbox. Below is my code for the aspx page and also for my code behind page. Can someone please tell and show me where I am going wrong? aspx page:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AspNetPolyDraw.Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML...

Issue with getting values from child controls in a gridview, to use for the update using a SQLDataSource control
Hi all, I have a gridview bound with a SQLDataSource. I am using the Update feature of the SQLDataSource to update a SQL Server database with values entered into the gridview. However I am not getting it to work. I believe this is due to the controls that contain the user entries are not the gridview itself, but rather child controls within the gridview. I have been using the names of the actual controls but nothing happens. Upon submit, the screen returns blank, and the database is not updated. Here is some code:   <asp:GridView ID="GridEditSettlement" runat="server" AutoGenerate...

GridView child of GridView
I have a Parent GridView and when you click in the Edit one of the columns has a Template Field which has a Child GridView. When you click Edit on the Child GridView I have a Template Field that has a TextBox. How to I retreive this value of the TextBox? GridViewParent-- GridViewChild (Edit - Template Field containing this GridViewChild)----- TextBox inside Template Field in GridViewChild. Thank you.Peace in ChristMarco Napolihttp://www.ourlovingmother.org What you can do as a solution is to override the RowDataBound and try to find the child GridView control. Once you get a reference to...

Problem Validating server control textboxes and HTML input txt fields inside a formview control
I have tried everything in the book and have not been able to come up with a solution. Have tried a custom validator calling a javascript funtion, but it doesnt work properly.  Have tried other ways, but it seems that one side works and the other doesn't as expected in everything I have tried. Anyone out there with similar problem that have found a solution.  Is it better to write a javascript to handle all validation rather than using server  side validators with the help of js functions?.  One of the problems is dealing with the insert button inside the formview, ...

Controlling User Input into a TextBox control
I want to control user input to a textbox control with a string mask. e.g. "99.9.99" where the 9s represent any numeric and the dots are automatically provided from the mask. Is it possible in an ASP.net page - it is standard in dBase type languages! Would it require Javascript? Where could I find help on this? Try using a RegularExpression Validator Control, which is part of the Asp.Net toolbox. Check out RegExLib.com for patterns and testing.RegardsAndre Colbiornsen ---------------------------------Seventh DayRåbygatan 1A,SE-223 61 LundSwedenMob.: +46-(0)708-...

Getting value from a textbox control that was filled with a value from javascript
 I have a textbox control (seen below txtMileageDollars1) that gets filled with javascript based on the number of miles a user types into another textbox (txtMileageMiles1) control.  When I post back with the submit button, the value is blank.  I've tried setting EnableViewState to false, but still cannot get a value on postback.  Does anyone have a solution?   Miles<asp:TextBox ID="txtMileageMiles1" runat="server" Width="50px"></asp:TextBox>   Total (txtMileageMiles1 * rate with javascript)<asp:TextBox...

Problem Using Slider Control in Gridview Control
Hello to all,   it is urgent.   i want to use slider control in a Gridview Template Column, if someone can help me how i can get this functionality?...

Control In Control Problem
Hi, guys.I've written two web controls for reservation system.One is a Datepicker which alows user to pick a date (pretty obvious ) and another one is a Reservation which alows user to pick a location (hotel) and number of rooms and number of people in each room.Both of them inherit WebControl and implement ICallbackEventHandler and INamingContainerI bind to them list with available days... List of hotels and regions (if it's to be used for reservation in hotels chain) well... whatever...Both of them work great while I don't try to include the DatePicker in the Reservation... Her...

Web resources about - Problem getting an input value from a textbox in a GridView control - asp.net.presentation-controls

GridView SelectedItem Binding Gotcha in WinRT
Last night when I was doing some WinRT hacking I was trying to setup databinding to the selected item in the GridView control and I ran into ...

CNW Group
Home Services Beyond the Wire About CNW Financials Webcasts Events My CNW All News Releases Advanced Search Gridview Latest News Releases All ...

CNW Group
... Services Beyond the Wire About CNW my CNW CNW Access CNW Directories Financials Webcasts Events my CNW All News Releases Advanced Search Gridview ...

CNW Group
Home Services Beyond the Wire About CNW Financials Webcasts Events My CNW All News Releases Add a Filter Gridview Latest News Releases All Today ...

New CmdLets of Powershell 2.0
New CmdLets of Powershell 2.0

Price Drop: Softbox
... objects- create product reflection- changing the background with something more interestingUse it as:- softbox- honeycomb softbox- gridview ...

Profile.aspx: ASP Alliance
.NET,ASP,ASP.NET,SQL,XML,HTML,ADO,ADO.NET,JavaScript,JScript,CSharp,VBScript and VB tutorials from AspAlliance.

Quick Answers - CodeProject
Questions - Free source code and tutorials for Software developers and Architects.; Updated: 25 Oct 2012

DotNetKicks.com - Upcoming stories
DotNetKicks.com is a community based news site edited by our members. It specialises in .NET development techniques, technologies and tools including ...

View Features - ExtendASP
Call 847-681-9827 or Request a Demo View Features Testimonials Pricing About Us Coming Soon ExtendASP exposes every feature, more than any other ...

Resources last updated: 1/6/2016 1:18:14 AM