473,387 Members | 1,579 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Problem with getting the value on GridView

I'm working with GridView. But it seems rough.
When I add a Command Field (Edit, Update image button type) handly. The OnRowUpdating doesn't fire when I click on Update button.

Then I change by delete the Command Fiel I've created and use AutoGenerateEditButton property of the GridView and it does work. The function OnRowUpdating does fire.

But I've got another trouble with this way.
I can't get the changed value of the textbox in editting mode.

Here is my code:
Expand|Select|Wrap|Line Numbers
  1. <asp:GridView ID="grvDsMatHang" runat="server" 
  2.                 AutoGenerateColumns="true" AllowPaging="True" 
  3.                 PageSize="5" Width="98%" 
  4.                 OnRowCancelingEdit="grvDsMatHang_RowCancelingEdit" 
  5.                 OnRowEditing="grvDsMatHang_RowEditing" 
  6.                 OnRowUpdating="grvDsMatHang_RowUpdating"
  7.                  AutoGenerateEditButton="true" 
  8. AutoGenerateDeleteButton="true" >
...<some definittions here>

Expand|Select|Wrap|Line Numbers
  1. <EditItemTemplate>
  2. //my TextBox in editting mode
  3.        <asp:TextBox ID="txtTenMH" runat="server" Text='' idth="50px"></asp:TextBox>
  4.  
  5.        <asp:HiddenField ID="hdnMoTa" runat="server" Value='<%# DataBinder.Eval(Container,"DataItem.MOTA") %>' />
  6.  
  7. </EditItemTemplate>
My code in .cs file to get the changed value of the TextBox

Expand|Select|Wrap|Line Numbers
  1. String n_Ten_MH = (row.FindControl("txtTenMH") as TextBox).Text;
The the value of n_Ten_MH still equals "" even I did type something in that textbox

Thanks in advance for noting my problems
Oct 9 '08 #1
2 1288
kenobewan
4,871 Expert 4TB
Here is a quickstart article that may help:
Gridview
Oct 9 '08 #2
Frinavale
9,735 Expert Mod 8TB
Are you doing a DataBind on your GridView in your PageLoad?
If you do a DataBind on your GridView before the Edit occurs, you will lose the data that was entered while editing.

-Frinny
Oct 9 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: WebBuilder451 | last post by:
I have a grid view and filter it based on an event from another control. I set the filter and it works fine, but when i page it reverts back to the full set of data from the datasource. How can i...
3
by: shapper | last post by:
Hello, In my GridView I have a HyperLink Field where I set the DataNavigateUrlFormaString MyHyperLinkField.DataNavigateUrlFormatString = "~\RSS.ashx?Channel={0}&Culture=" &...
3
by: needin4mation | last post by:
In this code: protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DataRowView rowView =...
6
by: Greg | last post by:
Hello, I have a GridView bound to a custom object. I set the DataKeyNames property along with the column DataField properties at design time, and bind the GridView to my object at run-time. In...
3
by: David C | last post by:
I have a GridView and when the SelectedIndexChange occurs I want to put the value of a BoundField into a TextBox (txtPropertyID) on the page. Below is the code I am using but it is not getting the...
0
by: db007 | last post by:
I have a problem at the moment with a web project. I have two Panels within an UpdatePanel on an aspx page (using Masterpages). I'm using ASP.Net 2.0 with an AJAX enabled website. The two...
11
by: Ed Dror | last post by:
Hi there, I'm using ASP.NET 2.0 and SQL Server 2005 with VS 2005 Pro. I have a Price page (my website require login) with GridView with the following columns PriceID, Amount, Approved,...
1
by: siri11 | last post by:
Hi everyone... I'm developing an application in asp.net with C#.net and Sqlserver as backend connecting to a local server.In one of the web forms the requirement is such that when I select an...
0
by: Jeff | last post by:
hi there ;) asp.net 2.0 I'm having problem with paging in GridView, I'm using custom paging. The ObjectDataSource reads in the rows needed for displaying each page as each page is selected....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.