I have a form that has 2 dropdowns.
First dropdown and with ajax I fill the second dropdown onclick
of button I store both these values in database.
Now i want to display the stored value in the dropdown bt i am nt understanding how shall i do this.
public void ddldropdown1_SelectedIndexChanged(object sender, EventArgs e)
{
IApplicationContext ctx = ContextRegistry.GetContext();
IServices reg = (IServices)ctx.GetObject("Services");
Int16 ID = Convert.ToInt16(ddldropdown1.SelectedValue);
if (ID != 0)
{
IList listDate = reg.getDateList(ID);
int Count = listDate.Count;
for (int i = 0; i < Count; i++)
{
DateList obj = new DateList();
obj = (DateList)listDate[i];
string strDate = obj.selectDate.Day.ToString() + "/" + obj.selectDate.Month.ToString() + "/" + obj.selectDate.Year.ToString();
ddlDatedropdown.Items.Add(new ListItem(strDate, strDate));
}
}
}
//Code for Save button
protected void btnSave_Click(object sender, EventArgs e)
{
IApplicationContext ctx = ContextRegistry.GetContext();
IServices reg = (IServices)ctx.GetObject("Services");
int Dropdown1ID = Convert.ToInt32(ddldropdown1.SelectedValue);
string strDate = "";
strDate = ddlDatedropdown.SelectedValue.Split("/".ToCharArray())[1] + "/" + ddlDatedropdown.SelectedValue.Split("/".ToCharArray())[0] + "/" + ddlDatedropdown.SelectedValue.Split("/".ToCharArray())[2];
DateTime SelectDate = Convert.ToDateTime(strDate);
if(reg.confirmGDPIRegistration(Dropdown1ID , strDate))
{
messagebox.show("saved");
}
}
Inside the aspx Page i hav declared the second dropdown like this -
<asp:DropDownList ID="Datedropdown" runat="server">
<asp:ListItem Value = "-- Select --">-- Select --</asp:ListItem>
</asp:DropDownList>
Inorder to display i do this-
DataSet ds = reg.getData(PID);
if (ds.Tables.Count> 0)
{
ddldropdown1.SelectedValue = ds.Tables[0].Rows[0]["ID"].ToString();
//how to do this for date????
}
For the First Dropdown i can fetch the value, but my question is:
- How can I fetch and display the date for the second dropdown?