473,672 Members | 2,603 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get TextBox ID

A DataGrid has a BoundColumn, an EditCommandColu mn & a few
TemplateColumns . When the text in the EditCommandColu mn within any of
the DataGridItems is clicked, the corresponding BoundColumn changes to
a TextBox.

How do I get the ID of such a TextBox?

Mar 11 '07 #1
3 3724
On 11 Mar 2007 13:22:37 -0700, rn**@rediffmail .com wrote:
A DataGrid has a BoundColumn, an EditCommandColu mn & a few
TemplateColumns . When the text in the EditCommandColu mn within any of
the DataGridItems is clicked, the corresponding BoundColumn changes to
a TextBox.

How do I get the ID of such a TextBox?
You need to set the onRowCommand and retrieve the cell by its offset in the
row that is clicked

... See
http://www.thescripts.com/forum/thread454303.html

This is code from one of my gridviews

-snip---aspx---------
onRowCommand="s preadEditOnRowC ommand"
DataSourceID="S qlDataSource6"
ForeColor="Blac k"
GridLines="Vert ical"
Style="z-index: 101; left: 0px; position: absolute; top: 250px">
<FooterStyle BackColor="#CCC C99" />
<Columns>
<asp:ButtonFiel d ButtonType="But ton" CommandName="De tails" Text="Sync" />
<asp:BoundFie ld DataField="umen o" HeaderText="ume no" ReadOnly="True"
SortExpression= "umeno" />
<asp:BoundFie ld DataField="arti cleno" HeaderText="art icleno"
ReadOnly="True" SortExpression= "articleno" />
<asp:BoundFie ld DataField="spre adno" HeaderText="spr eadno"
ReadOnly="True" SortExpression= "spreadno" />
<asp:BoundFie ld DataField="desc ription" HeaderText="des cription"
SortExpression= "descriptio n" />
<asp:BoundFie ld DataField="spre adimage" HeaderText="spr eadimage"
SortExpression= "spreadimag e" />
</Columns>

-snap----aspx.cs--------
protected void spreadEditOnRow Command(object src, GridViewCommand EventArgs
e)
{
if (e.CommandName == "Details")
{
// get the row index stored in the CommandArgument property
int index = Convert.ToInt32 (e.CommandArgum ent);
// get the GridViewRow where the command is raised
GridViewRow selectedRow = ((GridView)e.Co mmandSource).Ro ws[index];
// get the spreadno
string spreadSpreadNo = selectedRow.Cel ls[3].Text;
// Store the spreadno
Session["spreadno"] = spreadSpreadNo;
}
}
--snop-----------

Mark
Mar 11 '07 #2
On Mar 12, 4:13 am, mark carew <markca...@magi cwanddept.com.a uwrote:
On 11 Mar 2007 13:22:37 -0700, r...@rediffmail .com wrote:
A DataGrid has a BoundColumn, an EditCommandColu mn & a few
TemplateColumns . When the text in the EditCommandColu mn within any of
the DataGridItems is clicked, the corresponding BoundColumn changes to
a TextBox.
How do I get the ID of such a TextBox?

You need to set the onRowCommand and retrieve the cell by its offset in the
row that is clicked

.. Seehttp://www.thescripts. com/forum/thread454303.ht ml

This is code from one of my gridviews

-snip---aspx---------
onRowCommand="s preadEditOnRowC ommand"
DataSourceID="S qlDataSource6"
ForeColor="Blac k"
GridLines="Vert ical"
Style="z-index: 101; left: 0px; position: absolute; top: 250px">
<FooterStyle BackColor="#CCC C99" />
<Columns>
<asp:ButtonFiel d ButtonType="But ton" CommandName="De tails" Text="Sync" />
<asp:BoundFie ld DataField="umen o" HeaderText="ume no" ReadOnly="True"
SortExpression= "umeno" />
<asp:BoundFie ld DataField="arti cleno" HeaderText="art icleno"
ReadOnly="True" SortExpression= "articleno" />
<asp:BoundFie ld DataField="spre adno" HeaderText="spr eadno"
ReadOnly="True" SortExpression= "spreadno" />
<asp:BoundFie ld DataField="desc ription" HeaderText="des cription"
SortExpression= "descriptio n" />
<asp:BoundFie ld DataField="spre adimage" HeaderText="spr eadimage"
SortExpression= "spreadimag e" />
</Columns>

-snap----aspx.cs--------
protected void spreadEditOnRow Command(object src, GridViewCommand EventArgs
e)
{
if (e.CommandName == "Details")
{
// get the row index stored in the CommandArgument property
int index = Convert.ToInt32 (e.CommandArgum ent);
// get the GridViewRow where the command is raised
GridViewRow selectedRow = ((GridView)e.Co mmandSource).Ro ws[index];
// get the spreadno
string spreadSpreadNo = selectedRow.Cel ls[3].Text;
// Store the spreadno
Session["spreadno"] = spreadSpreadNo;
}
}
--snop-----------

Mark
Mark, I am using a DataGrid & NOT a GridView & DataGrid doesn't have
any event named RowCommand! So I can't use the RowCommand event.

Any other ideas/suggestions using a DataGrid?

Mar 12 '07 #3
Hello rn5,

If you're using a DataGrid control, you probably want to handle either the
ItemEdit command or the UpdateCommand, depending on what you're exactly
doing. My guess is that you want to handle the update and are looking for
user input. For either case you want to look in the e.Item.Cells collection
for the controls. If you're developing for version 2 of the .NET Framework,
you might want to take a look at the GridView control.
=-=-=-
void ItemsGrid_Updat e(Object sender, DataGridCommand EventArgs e)
{

// Retrieve the text boxes that contain the values to update.
// For bound columns, the edited value is stored in a TextBox.
// The TextBox is the 0th control in a cell's Controls collection.
// Each cell in the Cells collection of a DataGrid item represents
// a column in the DataGrid control.
TextBox qtyText = (TextBox)e.Item .Cells[3].Controls[0];
TextBox priceText = (TextBox)e.Item .Cells[4].Controls[0];

// Retrieve the updated values.
String item = e.Item.Cells[2].Text;
....... // more processing

--
brians
http://www.limbertech.com
"rn**@rediffmai l.com" wrote:
On Mar 12, 4:13 am, mark carew <markca...@magi cwanddept.com.a uwrote:
On 11 Mar 2007 13:22:37 -0700, r...@rediffmail .com wrote:
A DataGrid has a BoundColumn, an EditCommandColu mn & a few
TemplateColumns . When the text in the EditCommandColu mn within any of
the DataGridItems is clicked, the corresponding BoundColumn changes to
a TextBox.
How do I get the ID of such a TextBox?
You need to set the onRowCommand and retrieve the cell by its offset in the
row that is clicked

.. Seehttp://www.thescripts. com/forum/thread454303.ht ml

This is code from one of my gridviews

-snip---aspx---------
onRowCommand="s preadEditOnRowC ommand"
DataSourceID="S qlDataSource6"
ForeColor="Blac k"
GridLines="Vert ical"
Style="z-index: 101; left: 0px; position: absolute; top: 250px">
<FooterStyle BackColor="#CCC C99" />
<Columns>
<asp:ButtonFiel d ButtonType="But ton" CommandName="De tails" Text="Sync" />
<asp:BoundFie ld DataField="umen o" HeaderText="ume no" ReadOnly="True"
SortExpression= "umeno" />
<asp:BoundFie ld DataField="arti cleno" HeaderText="art icleno"
ReadOnly="True" SortExpression= "articleno" />
<asp:BoundFie ld DataField="spre adno" HeaderText="spr eadno"
ReadOnly="True" SortExpression= "spreadno" />
<asp:BoundFie ld DataField="desc ription" HeaderText="des cription"
SortExpression= "descriptio n" />
<asp:BoundFie ld DataField="spre adimage" HeaderText="spr eadimage"
SortExpression= "spreadimag e" />
</Columns>

-snap----aspx.cs--------
protected void spreadEditOnRow Command(object src, GridViewCommand EventArgs
e)
{
if (e.CommandName == "Details")
{
// get the row index stored in the CommandArgument property
int index = Convert.ToInt32 (e.CommandArgum ent);
// get the GridViewRow where the command is raised
GridViewRow selectedRow = ((GridView)e.Co mmandSource).Ro ws[index];
// get the spreadno
string spreadSpreadNo = selectedRow.Cel ls[3].Text;
// Store the spreadno
Session["spreadno"] = spreadSpreadNo;
}
}
--snop-----------

Mark

Mark, I am using a DataGrid & NOT a GridView & DataGrid doesn't have
any event named RowCommand! So I can't use the RowCommand event.

Any other ideas/suggestions using a DataGrid?

Mar 12 '07 #4

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

Similar topics

0
2118
by: Jonas L | last post by:
Hi, I need to create a textbox which acts as a normal textbox but with the following extra requirements: 1) In-focus color, when the textbox gets focus the backcolor property of the textbox should be set to a, selectable, in-focus color. 2) Out-of-focus color, when the textbox loses focus the backcolor property of the textbox should be set to a, selectable, out-of-focus color.
4
2906
by: Rodrigo DeJuana | last post by:
Howdy, I'm new to this .net stuff and really have little to no training. Im trying to create a new page for a web form, so i have been pretty much jsut coping code. I having some issue with some textboxes not updating when i a hit save. for example I have this code in my aspx.cs file: declared:
0
1810
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 first values for each control. Please help me. Thanks for any help. Bye Ozer And here's my code: Imports System Imports System.Data Imports System.Data.OleDb
7
2115
by: I am Sam | last post by:
I have a DataGrid that is passing information to a stored procedure properly but the parameters aren't being casted properly. I was woundering if anyone can tell me how I should properly cast the following: (TextBox)UserPrefix=(TextBox)e.Item.Cells.Controls; string strUserPrefix=UserPrefix.Text; I keep getting the following error and I don't know why because I have declared the UserPrefix as a textbox using "protected...
11
4542
by: Keith | last post by:
I apologize for those of you who think I'm posting on the same topic. It is not that I don't appreciate all of your comments - and I'm definitely reading them all - but I think I have a differing opinion of how I want to handle the 'user experience' in the application I'm creating. While I know I could allow the user to enter in number and alpha text - in a text box - and then tell them when the execuate a command "This is not numeric data", I...
2
19853
by: Mamatha | last post by:
Hi I want to add an icon to the textbox's text. I don't know how to display icon in textbox in VB.NET. If any one knows please let me know. Thanks in advance. Mamatha
3
2216
by: Brad Rogers | last post by:
All, Being immersed in vb.net and trying CSharp after almost a year I forgot the differences. I like vb fixing the uppercase/lowercase names and seeming to be more flexible to code entry. But while trying to insert a text box to see when a method is used, and putting a counter to bump some variable? The textbox sits there unchanged. I put a breakpoint at the text write
0
2396
by: Jacob Donajkowski | last post by:
Once the user logs in I want to have the users switch from the Roster View to the Profile View and enter their profile infomation and save it. Then the next time they login and go to the Profile View I want the form populated from there profile on the sql server. The code to save the profile works fine. But when the user logs back in they data doesn't load back to the form. The multiview is located inside the LoginView's Logged-In View ....
8
36879
by: Marco Pais | last post by:
Hi there. How can I change the background color of a textbox when it gets the focus? I can handle the "Enter" event and do this private void txtDummie_Enter(object sender, EventArgs e) { txtDummie.BackColor=Color.Red; }
1
1619
by: Andy B | last post by:
I have this code: protected void EditEventsWizard_NextButtonClick(object sender, WizardNavigationEventArgs e) { //get the values from the DetailsView TextBox StartTime = (TextBox)EditEventForm.Rows.Cells.Controls; TextBox EndTime = (TextBox)EditEventForm.Rows.Cells.Controls;
0
8486
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8404
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8931
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8828
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8608
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8680
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6238
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5705
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
2063
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.