473,382 Members | 1,545 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,382 software developers and data experts.

set selectedvalue on dropdown in datagrid

I have a datagrid that includes a dropdown in an edit template. It creates
ok, but i'm not sure how to set the selectedvalue based on the table in the
dataset.
given that the dataset DsSubTypes1 what is the best way to get the current
value. If it can be taken from the datagrid i'd like to know how.
My sub to populate the dropdownlist is below.
thanks
kes
If e.Item.ItemType = ListItemType.EditItem Then
Dim thsddl As DropDownList =
e.Item.Cells(4).Controls(0).FindControl("ddlTF")
thsddl.DataSource = DsSubTypes1
thsddl.DataTextField = "TFDesc"
thsddl.DataValueField = "TFValue"
thsddl.DataBind()

'thsddl.SelectedValue =
End If
Nov 19 '05 #1
1 1143
Ok I can get it to work, but i'm using a hidden databound column. Is there a
better way?

"Kurt Schroeder" wrote:
I have a datagrid that includes a dropdown in an edit template. It creates
ok, but i'm not sure how to set the selectedvalue based on the table in the
dataset.
given that the dataset DsSubTypes1 what is the best way to get the current
value. If it can be taken from the datagrid i'd like to know how.
My sub to populate the dropdownlist is below.
thanks
kes
If e.Item.ItemType = ListItemType.EditItem Then
Dim thsddl As DropDownList =
e.Item.Cells(4).Controls(0).FindControl("ddlTF")
thsddl.DataSource = DsSubTypes1
thsddl.DataTextField = "TFDesc"
thsddl.DataValueField = "TFValue"
thsddl.DataBind()

'thsddl.SelectedValue =
End If

Nov 19 '05 #2

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

Similar topics

0
by: Kilic Beg via .NET 247 | last post by:
Hi, I am having trouble adding a dropdown to DataGrid at runtime. I create all boundColumns and the TemplateColumn for the dropdown at runtime. The dropdown has a different datasource then the...
8
by: Supa Hoopsa | last post by:
I have a databound combobox within a datagrid. I have set the DisplayMember and ValueMember. BUT, how do I capture the Value (SelectedValue) when the user changes the selection?
3
by: Steven | last post by:
Hi there, I am having a problem with an ASP.NET DropDown list - whenever I set the SelectedValue (or SelectedIndex) property, when the page displays, only the first item is ever selected. This...
1
by: Vijay Kerji | last post by:
Hi, I have a datagrid with dropdown list and Remove hyperlink in it as columns. When I remove a row from the datagrid, Dropdown list selection is retaining its previous value. i.e, removed...
5
by: Stimp | last post by:
Hi all, I've come back to this problem again and I've identified which part of my code is producing the error: "'SelectedIndex' and 'SelectedValue' attributes are mutually exclusive" I...
6
by: Mike Caputo | last post by:
Shouldn't I be able to set the selected item of a combobox with the SelectedValue property? The ComboBox has four items, the values are 1 through 4. Here's an example of what I'm trying to do: ...
8
by: CK | last post by:
Hi All, I have a class and one property is an Enum. I am trying to persist the DropDownList.SelectedValue to the class property. I am using job.ExpRelated =...
2
by: Peter | last post by:
ASP.NET 2003 In the DataGrid how do I select current cell value in the dropdown box when I click on the edit link, currently when I click on the edit link in the DataGrid the dropdown box...
5
by: jung_h_park | last post by:
From: jung_h_park@yahoo.com Newsgroups: microsoft.public.dotnet.framework.aspnet Subject: Dropdown List not retaining its SelectedValue Date: Mon, 26 Jun 2006 21:02:57 -0700 Hello, My...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.