get textbox text value from gridview in editmode

I am using gridview. In the edititemplate section I have textBoxes for the fields. (I am using TemplateField) 

 i am trying to perform an update. In this method:

protected void TimeTable_RowUpdating(object sender, GridViewUpdateEventArgs e) 

  when i try to access a textBox like this:

  string h9 = ((TextBox)TimeTable.Rows[e.RowIndex].Cells[1].Text.Controls[0]).Text;

Or:

 string h9 = ((TextBox)TimeTable.Rows[e.RowIndex].Cells[1].Text.Controls[1]).Text;

  It throws an exception:

"Specified argument was out of the range of valid values.
Parameter name: index"

 


I also tried the following:

string h9 = ((TextBox)TimeTable.Rows[e.RowIndex].FindControl("TextBox9")).Text;

this does not throw any exceptions, but it gives the old value of the text box, not the newly inserted one for some reason. 

 

how do i get the text of the textbox in the gridview?? 

thanks 

 

0
raklos
9/17/2007 9:51:20 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

1 Replies
928 Views

Similar Articles

[PageSpeed] 14

Oh dear! this was the problem, i was missing this!! grrrrrrrrr 

        if (!IsPostBack)
        {
            BindGrid();
        }

0
raklos
9/17/2007 9:55:15 PM
Reply:

Similar Artilces:

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....

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...

Custom web control. Get Textbox.text value
Hi I have created a custom web control that extends the CheckBoxList control. It basically is a CheckBoxList control that has a TextBox added to the end of each CheckBox. It looks like the following after it has being bound to a database table column. I need to be able to retrieve the values in the corresponding TextBox when a CheckBox is selected. I tried storing each TextBox in an ArrayList but it is always empty when I try and check it. I am pretty new to ASP and am obviously missing something. Has anybody here got any tips or ideas on how I could retrieve the data from the TextBoxes...

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...

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 populate...

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...

How to get the value of a textbox that has been added to a template field in a gridview. VB.Net
I have a gridview that shows products, description, price. I have added a Buttonfield and a TemplateField that has a Textbox with the id QuantityTextBox.What I am trying to do is get the value of the Quantity TextBox in the RowCommand event of the gridview. I can get the price but need to get the quantity also. To get the price I used ItemPrice = Server.HtmlDecode(row.Cells(5).Text) My template field is cell 6 but the above routine does'nt work. Any help would be greatly appreciated.Dan5150www.5150creations.com Hiuse this: VB:  Protected Sub GridView1_RowCommand(ByVal ...

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...

Set TextBox text value to value from DataList Control
I'm sure this is a totally sad question to ask, but... I am using a DataList View to display data. I have a separate form within a LoginView that I would like to use to update a few main fields. I want to set the Text property of the TextBox in my custom edit form to the value of the corresponding field in the DataList. Is this possible? I think i get your question --> you want the text from a  textbox from the datalist to be input into a textbox within your form? try:TextBox tb = DataList1.FindControl("TextBoxIDToFind"); TextBoxOnForm.Text = tb.Text;David Ki...

length or trim ? how can i get textbox.text as text that publichouse to textbox.text as text that public ?
hello friends length or trim ? how can i get textbox.text as text that publichouse to textbox.text as text that public ? second example is ..... textbox1.text is greenhouse.. i want to get green from textbox.text cheer Mark as me if my question or my answer can be helpful for you :) Hi,you can always perform a Trim to a retrieved string to delete the leading and trailing space characters. For your second example where you want to gt a part of the retrieved string you can use the SubString method of the String class.Grz, Kris. Read my blog. Handy Firefox plugins for web developers.Workar...

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...

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...

How to get the Value from the Textbox ?Textbox is created by using add control function.
  Dim textWG As New HtmlInputText textWG.text="Wage Rate" textWG.ID = "txtWG" me.control.add(textWG) i write this code at form load.moreover this form have one save button to save the value from the "txtWG" to database this textbox will be appear when form finish load.but after click save button the value cant be save into database. tat textbox become empty when user click the save button. how can i get the value from that textbox ? Please advice me.Thank you You are using a HTML control and by default, HTML controls dont have a mechanism to pres...

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...

Web resources about - get textbox text value from gridview in editmode - 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: 12/21/2015 3:05:14 AM