473,406 Members | 2,273 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,406 software developers and data experts.

help finding an item in a datagrid

Using:
DataGrid1_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
DataGrid1.ItemCommand

is there a way to find a specific item in the datagrid. I'm using the
CommandEvent to do some stuff. When I try to use syntax like this:

e.Item(1).FindControl("txtQuestion"), TextBox).Text

or other variations is says that e.item can not be used to find a particular
row, etc.

If there are say 5 rows in the datagrid and I want control("txtQuestion") on
row 2, how do I get that?

Once I click the commandevent I have the row, and fields, I'm on. But I also
need other rows values????

Make sense?

Thanx.

Nov 19 '05 #1
4 2285
Hi Hope this helps,
I am using the following code to set some parameters in a dropdown box that
is a control in a data grid. This seems to work ok.
Dim dr_ctrl As DropDownList
dr_ctrl = CType(e.Item.Cells(8).FindControl("dr_lst_orig"), DropDownList)
dr_ctrl.Items.Insert(0, "Select ..")
dr_ctrl.SelectedIndex = 0

"Chris" wrote:
Using:
DataGrid1_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
DataGrid1.ItemCommand

is there a way to find a specific item in the datagrid. I'm using the
CommandEvent to do some stuff. When I try to use syntax like this:

e.Item(1).FindControl("txtQuestion"), TextBox).Text

or other variations is says that e.item can not be used to find a particular
row, etc.

If there are say 5 rows in the datagrid and I want control("txtQuestion") on
row 2, how do I get that?

Once I click the commandevent I have the row, and fields, I'm on. But I also
need other rows values????

Make sense?

Thanx.

Nov 19 '05 #2
I'm not sure how this fits into my need.
You use cells(value) to locate the control, I can't. It's not available
apparently in CommandEventArgs.

"e.Item(1).FindControl("txtQuestion"), TextBox).Text

or other variations is says that e.item can not be used to find a particular
row, etc."

I'm on the code-behind.

Thanx.

"Paul" wrote:
Hi Hope this helps,
I am using the following code to set some parameters in a dropdown box that
is a control in a data grid. This seems to work ok.
Dim dr_ctrl As DropDownList
dr_ctrl = CType(e.Item.Cells(8).FindControl("dr_lst_orig"), DropDownList)
dr_ctrl.Items.Insert(0, "Select ..")
dr_ctrl.SelectedIndex = 0

"Chris" wrote:
Using:
DataGrid1_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
DataGrid1.ItemCommand

is there a way to find a specific item in the datagrid. I'm using the
CommandEvent to do some stuff. When I try to use syntax like this:

e.Item(1).FindControl("txtQuestion"), TextBox).Text

or other variations is says that e.item can not be used to find a particular
row, etc.

If there are say 5 rows in the datagrid and I want control("txtQuestion") on
row 2, how do I get that?

Once I click the commandevent I have the row, and fields, I'm on. But I also
need other rows values????

Make sense?

Thanx.

Nov 19 '05 #3
If there are say 5 rows in the datagrid and I want control("txtQuestion") on row 2, how do I get that?


Hmm.... i may be missing out on something, but how would this work for you?
Label1.Text = CType(DataGrid1.Items(2).FindControl("txtCompany") ,
TextBox).Text

Now.... this requires that the txtCompany textbox is in a template column,
and ofcourse that the textbox is named "txtCompany".

Hope it helps.
Jeppe Jespersen
Nov 19 '05 #4
Thanx! don't know how I missed that.

"Jeppe Dige Jespersen" wrote:
If there are say 5 rows in the datagrid and I want control("txtQuestion")

on
row 2, how do I get that?


Hmm.... i may be missing out on something, but how would this work for you?
Label1.Text = CType(DataGrid1.Items(2).FindControl("txtCompany") ,
TextBox).Text

Now.... this requires that the txtCompany textbox is in a template column,
and ofcourse that the textbox is named "txtCompany".

Hope it helps.
Jeppe Jespersen

Nov 19 '05 #5

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

Similar topics

2
by: Sean | last post by:
Hi, I am facing a problem, and i don't know why the error is being generated. I am updating a datagrid with an XML file. My code is Protected Sub UpdateCommand(ByVal Sender As Object,...
1
by: MrNobody | last post by:
what I'd like to have is a simple feature to search within a column in a DataGrid and have that the first matching row selected, then the user can choose to search again where it will select the...
1
by: Mike | last post by:
I have an ASP.NET/VB app that updates values in a DataTable over the course of about 3 different pages. On the way out of the first of these pages, I explicitly build the DataTable from values in...
5
by: GaryB | last post by:
The datagrid.items collection only appears to have data rows in it. for Instance... dim myItem ad dataGridItem myItem = myGrid.Items(0) returns the first data row of data. How can I access...
10
by: Joe | last post by:
Hi, Tried using the FindControl() but no luck in finidng this damn textbox having id txtFirstName. Can someone help me with this method? This is what I have been doing but it doesn't work, ...
10
by: Terry Olsen | last post by:
I've got a datagrid set up to display data. I've also got an Edit,Update,Cancel column set up to allow editing of data. I've got a DropDownList (ID="ddl3")in the EditItemTemplate for a certain...
2
by: hansiman | last post by:
When I want to add a js confirm box to a delete button that is positioned in the last column in a datagrid row I do the following in the ItemDataBound event: Dim delBtn As LinkButton =...
7
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...
3
by: Datatable Dataset Datagrid help | last post by:
Hi I am somewhat confused, I am new at VB.net I use XML data, I have a datagrid, I created a datatable so that I can create a custom format like true is this graphic false is this graphic and...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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,...
0
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...
0
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.