Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Template Column

Reply
Thread Tools

Template Column

 
 
VJ
Guest
Posts: n/a
 
      04-06-2004
Hi...

This should be simple I guess.. I have a dropdownbox as a template column in
my datagrid. When the selected item changes in this dropdown item, I need to
know the corresponding datarow in the datagrid. How do I determine this?

VJ


 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      04-10-2004
If you handle DDL's SelectedIndexChanged event, you get the DDL instance
itself from the first parameter of event handler method. Ok, in the control
hierarchy DDL is inside a TableCell which is inside a DataGridItem (which
actually inherits from TableRow). Ok, so answer is that you cast the sender
event argument to DDL and get its parent's parent control something like:

DataGridItem item=(DataGridItem)((DropDownList)sender).Parent.P arent;

or straight with NamingContainer property:

DataGridItem item=(DataGridItem)((DropDownList)sender).NamingCo ntainer;

The trick here is that DataGridItem can return the index of the DataGridItem
in Items collection of DataGrid (or DataItem itself if you are databinding)
which you can use to access the correct data source row. If you are not
databinding as you probably are not when this is run, you need to somehow
refetch the data.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke

"VJ" <(E-Mail Removed)> wrote in message
news:%238O9aL$(E-Mail Removed)...
Hi...

This should be simple I guess.. I have a dropdownbox as a template column in
my datagrid. When the selected item changes in this dropdown item, I need to
know the corresponding datarow in the datagrid. How do I determine this?

VJ



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
setting Column width of Template Column in Datagrid.. Charleees ASP .Net 2 06-20-2006 12:52 PM
DataGrid loses view state if first column is a template column. Ken Varn ASP .Net 1 08-19-2005 02:54 PM
Template column base on another column value Esperanza ASP .Net Datagrid Control 5 02-21-2005 04:02 PM
how to know if a datagrid column is a template column? Dexter ASP .Net 1 01-18-2005 01:45 PM
Bound Column or Template Column (w dAdapater?) in DataGrid Ravichandran Mahalingam ASP .Net Datagrid Control 0 01-09-2004 03:30 PM



Advertisments