There is a Dropdown(named "Station") in my code.
<asp:DropDownList ID="DStation" runat="server" Width="100%"></asp:DropDownList>
Im fetching the data saved in DB inside dropdown SelectedValue on page load as below:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
showDamageData();
}
}
protected void showDamageData()
{
try
{
int id = Convert.ToInt32(Request.QueryString["id"].ToString());
this.query ="select Station from Table1 where id = '" + id + "'";
DataSet ds = DataManager.DatabaseManager.GetOrCreateConnection(DataManager.DatabaseManager.ConnectionType.MySQL).GetData(query);
creationdate.Text = ds.Tables[0].Rows[0][0].ToString();
DStation.SelectedValue = dataSet1.Tables[0].Rows[0][1].ToString();
}
catch(Exception ex)
{
}
}
Im fetching data from below DB table1 in "station" dropdown:
ID
|
Station
|
1
|
ABC
|
2
|
CH022
|
3
|
CH0234
|
4
|
CH76
|
5
|
CH983
|
But its always showing "ABC" (i.e, 1st Id's station) in selectedValue of dropdown, for every "id" dont know why.
What is the reason and how to solve it.
Please reply.