473,382 Members | 1,646 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.

DROPDOWN SELECTED PROPERTY PROBLEM

I have a Datagrid and it has a dropdown.

<asp:DropDownList DataSource="<%# PopulateList() %>" OnLoad="SelectIndex" >

I assign selected index of the my dropdown in SelectIndex function.
protected void SelectIndex(object source, System.EventArgs e)

{

DropDownList DXmlFirmalar = (DropDownList)source;

DataSet ds = (DataSet)DataGrid1.DataSource;

DataTable tb=ds.Tables[0];

DataRow row = tb.Rows[DataGrid1.EditItemIndex];

////////////////////////////

///

SqlConnection baglantim=con.MyConnect ();

DataSet ds1=new DataSet ();

ds1=con.GetFirmalar(baglantim);

int y=0;

foreach (DataRow item in ds1.Tables[0].Rows )

{

if (row["XmlFirmalar"].Equals(item["Firma_ID"].ToString()))

DXmlFirmalar.SelectedIndex=y;

y++;
}

}

When I try to update my grid
string XmlFirmalar
=((DropDownList)e.Item.FindControl("DXmlFirmalar") ).SelectedValue.ToString()
;

Response.write (XmlFirmalar);

It always returns 4 which is the default. I change my selection in the
dropdown but it returns 4

How can i solve it ?
Dec 5 '06 #1
3 1656

string XmlFirmalar
=((DropDownList)e.Item.FindControl("DXmlFirmalar") ).SelectedValue.ToString(*)

;
I think you should pharse the query with selectedIndex also.... you are
not selecting an index it seems...

atleast
comboBox1.SelectedIndex
is working for me in WinForms

Thanks
-Srinivas

<in da clubwrote:
I have a Datagrid and it has a dropdown.

<asp:DropDownList DataSource="<%# PopulateList() %>" OnLoad="SelectIndex" >

I assign selected index of the my dropdown in SelectIndex function.
protected void SelectIndex(object source, System.EventArgs e)

{

DropDownList DXmlFirmalar = (DropDownList)source;

DataSet ds = (DataSet)DataGrid1.DataSource;

DataTable tb=ds.Tables[0];

DataRow row = tb.Rows[DataGrid1.EditItemIndex];

////////////////////////////

///

SqlConnection baglantim=con.MyConnect ();

DataSet ds1=new DataSet ();

ds1=con.GetFirmalar(baglantim);

int y=0;

foreach (DataRow item in ds1.Tables[0].Rows )

{

if (row["XmlFirmalar"].Equals(item["Firma_ID"].ToString()))

DXmlFirmalar.SelectedIndex=y;

y++;
}

}

When I try to update my grid
string XmlFirmalar
=((DropDownList)e.Item.FindControl("DXmlFirmalar") ).SelectedValue.ToString()
;

Response.write (XmlFirmalar);

It always returns 4 which is the default. I change my selection in the
dropdown but it returns 4

How can i solve it ?
Dec 5 '06 #2
<select name="DataGrid1:_ctl3:DXmlFirmalar"
id="DataGrid1__ctl3_DXmlFirmalar">
<option value="1">Ereyon</option>
<option value="2">Kangurum</option>
<option value="3">SiberStore</option>
<option selected="selected" value="4">WebdenAl</option>
<option value="5">Weblebi</option>

</select>
string XmlFirmalar
=((DropDownList)e.Item.FindControl("DXmlFirmalar") ).SelectedIndex.ToString()
;

returns 3

string XmlFirmalar
=((DropDownList)e.Item.FindControl("DXmlFirmalar") ).SelectedValue.ToString()
;

returns 4

it doesnt care about my selection in html page.


Dec 5 '06 #3
ok i solve it

thanks..
Dec 5 '06 #4

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

Similar topics

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...
5
by: Kris Rockwell | last post by:
Hello (again), I have gotten the dropdown list functionality to work through a few tricks (probably not the most efficient, but it works) but I am not sure how to set the default selected value....
6
by: Mark | last post by:
I have two dropdown lists. Both have autopostback set to true. In both dropdowns, when you select an item from the list, it redirects to the Value property of the dropdown. Nothing fancy. ...
4
by: Simon Harvey | last post by:
Hi all, Am I being really stupid here: myDropDown.SelectedIndex = 2 I think this line should set the dropdown control's selected item to 2. But nothing seems to be happening on the page....
4
by: Paul | last post by:
I have a dropdown list box and a button on a web form, the autopost back is false for the dropdown list box and button. When the button is pushed the selection in the dropdownlist box is lost,...
6
by: | last post by:
Do you have to use AutoPostBack to read the selected value in a dropdown list? I have an asp.net dropdown on a form. I'm filling it from a table when the page loads and want to read the value the...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
0
by: cindy | last post by:
I have a dynamic datagrid. I have custom classes for the controls public class CreateEditItemTemplateDDL : ITemplate { DataTable dtBind; string strddlName; string strSelectedID; string...
0
by: Kay | last post by:
Hello, I have written my own custom control and I want one of its properties to display as a dropdown list when clicked, so the user can select from the list, it would be similar to the asp...
0
by: Kay O'Keeffe | last post by:
Hello, I have written my own custom control and I want one of its properties to display as a dropdown list when clicked, so the user can select from the list, it would be similar to the asp...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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:
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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.