Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Finding database values in ItemDataBound of a dg

Author  Topic 

Billkamm
Posting Yak Master

124 Posts

Posted - 2006-04-06 : 16:21:24
I have a datagrid where when you click the edit button dropdownlists appear for that row. However, I need a way to change the dropdownlist to the appropriate value (it always starts at the top). Does anyone know the syntax as to how I would obtain this value, so that I can update the dropdownlist?

Do I have to requery the database or is there a way to get the value from e As System.Web.UI.WebControls.DataGridItemEventArgs?

dfiala
Posting Yak Master

116 Posts

Posted - 2006-04-06 : 16:30:22
Dim drv a DataRowView = e.DataItem

Grab the value
Dim SelectedValue as String = drv("ColumnName")

so with it what you wish
Go to Top of Page

dfiala
Posting Yak Master

116 Posts

Posted - 2006-04-06 : 16:31:39
Should have been...
Dim drv AS DataRowView = e.DataItem

Grab the value
Dim SelectedValue as String = drv("ColumnName")

DO with it what you wish
Go to Top of Page

Billkamm
Posting Yak Master

124 Posts

Posted - 2006-04-06 : 17:39:11
Thanks, I actually just found out that my problem was I had hidden column in slot 0, so I was pulling the wrong value because of that and that was my problem. e.Item.DataItem works to get the row of information I need.
Go to Top of Page
   

- Advertisement -