473,503 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get values of a textbox in a datagrid?

I have a datagrid and I created a textbox and a button in a column of every
row. How do I make it such that when the user click the button, i can get the
value entered in the textbox, and how do I know which row are the textbox and
the button that is clicked located? And how do I include the button_Click
event in my code?

Does anyone has any idea? Thank you.
Nov 19 '05 #1
2 2083
Hi wrytat

Answer to the question : how do I include the button_Click event in my code?

First assign some value to commandName property to your button. When you
click the button the datagrid's ItemCommand event will trigger. There you
can handle that event by checking the commandname as like

Suppose i assigned "Add" as commandName for button
then in ItemCommand you can check which button is clicked

if(e.CommandName == "Add" )
{

//Add the code
}

To identify which button clicked, you can use CommandArgument property of
button.

To get the textbox value, first you get a reference to the textbox.

Textbox text1 = (TextBox)e.Item.FindControl("txtTest"); // txtTest is
textbox name
String someValue = text1.Text;

regards
charmis
Nov 19 '05 #2
> Suppose i assigned "Add" as commandName for button
then in ItemCommand you can check which button is clicked
What is an command argument? Where can I find it?
To identify which button clicked, you can use CommandArgument property of
button.

To get the textbox value, first you get a reference to the textbox.

Textbox text1 = (TextBox)e.Item.FindControl("txtTest"); // txtTest is
textbox name
String someValue = text1.Text;


What is ItemCommand? But I'll have so many text1 because I've a textbox in
every row.

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3181
by: Morné | last post by:
Hi how do I validate a text value in a datagrid e.g. the user is only allowed to type in a Y or a N. I specifically have a problem with using the PropertyDescriptorCollection. I get the...
0
1466
by: Paolo Tardivel via DotNetMonster.com | last post by:
I have a databound datagrid containing template columns which allow editing of the values contained in the datagrid through the use of text boxes. One of the fields in the datagrid displays the...
3
4920
by: Kevin Pedersen | last post by:
Hello, I am using an editable datagrid. After I save the changes the datagrid shows the old values. I've read the posts about the Page_Load and not binding the datagrid each time. The SQL that...
0
1044
by: Mike | last post by:
I've got an app with a DataTable that gets passed around and modified by datagrids on 3 different asp.net pages. Not all columns need to be displayed, but I need them all in the datagrid so I can...
0
1798
by: Newasps | last post by:
Hi guys, I have a problem with UpdateCommand Event. In tihs event Ä°'m creating required controls to get that controls' values and also get them. But when I try to get updated values I'm getting the...
0
1523
by: Ozer | last post by:
Hi guys, I need some help. In my datagrid's updatecommand event i'm trying to get textboxes values and also do it. But when i update the values in textboxes and fire the event, I can't get the...
3
1319
by: MaryA | last post by:
I have an asp.net application in which i have a form containing a datagrid when using the update command event i have: tb = CType(e.Item.Cells(3).Controls(0), TextBox) subject = tb.Text this code...
1
1379
by: Arjen Hoekstra | last post by:
Hello, I've got a datagrid with a textbox in each cell. I've also two buttons, one to add a row to the datagrid and one to delete a row. A user can type data into textboxes and then submit it to...
2
1684
by: Kiran Kumar Pinjala | last post by:
Hi, May be this is silly, or I just need a second pair eyes to look at this. I am trying to get values that I have edited in a datagrid and update the values with those values. Here is the code...
7
2177
by: Aaron | last post by:
Complete code follows. I am new to .NET programming (and programming in general) and I am having a difficult time understanding how to fill a variable in one sub, and then access it from...
0
7201
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
7083
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7278
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,...
1
6988
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7456
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5011
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1510
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.