开发者

how to get an selected value fora dropdown control inside detailsview control. when it is in edit mode

i have an detialsview control with item template and edititemtemplate. when user clciks the edit button in detailsview all the control are replaced with textbox control and dropdown control. but in dropdown control i have an issue in the read mode of detailsview control item template field is having value="India" when i click edit mode here now i am getting dropdown control with populating all the countries. as for this record the selected value should be "india" and then rest all the countries names should be coming in dropdown control

my code looks like this

public DataSet PopulateDropDownList()

{

SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["MyDatabase"].ConnectionString);

SqlDataAdapter ad = new SqlDataAdapter("SELECT * FRO开发者_运维问答M country", myConnection);

DataSet ds = new DataSet();

ad.Fill(ds, "country");

return ds; 

}
<ItemTemplate > 

' runat ="server" > " DataTextField="Phone" DataValueField = "PhoneID">

so in edit mode how can i show user the the this selected value in the dropdown should comefirst then follwd by other countries name

how can i achive this one here. looking for this solution from past 2 days any help would be great thank you


Your code snippet isn't complete, I think.

However: unless you have something to haul out the SelectedValue of the drop-down list and put it first, the drop-down list will have entries in the same order as the database query.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜