V
Viktor Popov
Hi,
When I place the following coede in Page_Load method it doesn't populate the
DropDownList and when I place it in Button1_Click method and I push the
button after the page is loaded the DropDownList is populated. What I should
do in order to populate the DropDownList when I reach this WebForm by link
from another WebForm?
SqlConnection conn = new SqlConnection("Data Source=BLEK;Initial
Catalog=Estate; User ID=blek; Password=banderas");
SqlDataAdapter dad = new SqlDataAdapter ("SELECT
blek.TypeOffer.OfferID,blek.TypeOffer.TypeOffer FROM blek.TypeOffer", conn);
conn.Open();
dad.SelectCommand.ExecuteNonQuery();
DataTable table=new DataTable();
dad.Fill(table);
DropDownList2.DataSource=table;
DropDownList2.DataValueField = "OfferID";
DropDownList2.DataTextField = "TypeOffer";
DropDownList2.DataBind();
msg.Text = table.Rows.Count.ToString();
conn.Close();
When I place the following coede in Page_Load method it doesn't populate the
DropDownList and when I place it in Button1_Click method and I push the
button after the page is loaded the DropDownList is populated. What I should
do in order to populate the DropDownList when I reach this WebForm by link
from another WebForm?
SqlConnection conn = new SqlConnection("Data Source=BLEK;Initial
Catalog=Estate; User ID=blek; Password=banderas");
SqlDataAdapter dad = new SqlDataAdapter ("SELECT
blek.TypeOffer.OfferID,blek.TypeOffer.TypeOffer FROM blek.TypeOffer", conn);
conn.Open();
dad.SelectCommand.ExecuteNonQuery();
DataTable table=new DataTable();
dad.Fill(table);
DropDownList2.DataSource=table;
DropDownList2.DataValueField = "OfferID";
DropDownList2.DataTextField = "TypeOffer";
DropDownList2.DataBind();
msg.Text = table.Rows.Count.ToString();
conn.Close();