473,406 Members | 2,713 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.

Get value from datagrid DDL cell OnSelectedIndexChange


I have a dropdownlist in a column of my datagrid. When
the user
changes the value in the ddl, I want to fire off
OnSelectedIndexChange
event and do an update based on the id held in a hidden
column of the
grid. But I cannot seem to get to that cell info from my
OnSelectedIndexChange procedure.

Here is some of the code:

[DATA GRID SETUP]

<Columns>
<asp:BoundColumn Visible=false ReadOnly=True
DataField="projDetailID"
HeaderText="ID" />
<asp:TemplateColumn headertext="% Complete"
SortExpression="PercentComplete" >
<ItemTemplate>
<asp:DropDownList id="ddlPercentComplete" runat="server"
AutoPostBack=True
OnPreRender="SetPercentIndex"
OnSelectedIndexChanged="RecordPercentDone"

</asp:DropDownList>
</ItemTemplate>
</asp:TemplateColumn>
</columns>
Public Sub RecordPercentDone(ByVal sender As Object, ByVal
e As
System.EventArgs)
'this is where I am trying to get the ID value of the row
'that the ddl index was changed
'once I get the ID, I can then write the real code for
the update

Dim ed As DropDownList = CType(sender, DropDownList)
Dim mylbl As Label = CType(ed.Parent.Parent.FindControl
("ID"),
Label)

Me.lblOutput.Text += mylbl.Text & "<BR>"

Dim dg As DataGrid = CType(ed.Parent.Parent, DataGrid)
Me.lblOutput.Text += mycell.Text & "<BR>"
Me.lblOutput.Text += dg.Items.Item(0).Cells
(0).Text.ToString() &
"<BR>"
Me.lblOutput.Text += ed.Parent.GetType.ToString & "<BR>"
End Sub

Thanks!!

Steve
Nov 17 '05 #1
1 1799
I figured out the solution.

Public Sub RecordPercentDone(ByVal sender As Object, ByVal
e As System.EventArgs)
Dim ed As DropDownList = CType(sender, DropDownList)
Dim myDatGridItem As DataGridItem = CType
(ed.Parent.Parent, DataGridItem)

Dim projDetailID As String = myDatGridItem.Cells(0).Text
Dim PercentComplete As String = ed.SelectedItem.Text
Do Update......
end sub


Nov 17 '05 #2

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

Similar topics

3
by: Dav | last post by:
I have a Winform with a derived datagrid and a button that adds a row to the datagrid in its Click event. The button has a shortcut text "&New Row". When I enter a value in a datagrid cell and...
1
by: Blake Versiga | last post by:
When editing a datagrid (C#) I need to know if the user changed the value of cell AND what the previous value was. Is this possible? If so how do I get the previous value or at least if the...
9
by: Paul | last post by:
Hi I have a data grid with a hyperlink column. the colum has numbers like 00001,000002, ect. Just wondering how to get the text value of the cell as tempstring =...
1
by: James | last post by:
I would like to get a value in a cell for the currently selected item in a DataGrid. The catch is I do not want to use an index number to access the cell. I want to use the DataField property of...
4
by: gugu | last post by:
Hi I have a datagrid which has 20 rows and 20 columns, 15 of 20 columns are checkboxs and their headertexts, datafields are dynamic. I need to loop through the whole page to see if the specific...
3
by: Jeff | last post by:
Help.. I have been using: string sId = ((System.Web.UI.WebControls.TextBox)e.Item.Cells.Controls).Text; To get the value of a cell in my datagrid. When I set the cell to read only, I get...
0
by: Matt | last post by:
I derived my own custom class from the datagrid class. I overrode the ProcessCmdKey Function, like this, to catch the up and down arrow keys: ====== Protected Overrides Function...
2
by: John Smith | last post by:
Will this line of the code: item.Cells.Text = "Some text..."; change only DataGrid visual value or it will also change value in the DataSource? How can I change value in DataSource? ...
2
by: harry | last post by:
Hi all, I have a datagrid (language C#) populated using a stored procedure. I want one of the column to display complete name instead of abbreviation. Can I change the display dynamically in the...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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,...
0
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...

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.