المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Combobox control..........??



C# Programming
06-25-2009, 01:22 PM
using vs2003.
Its a data entry application, having some fields and buttons.

In this, I am using combobox control, getting data from DB in DataTable obj dt, then setting the datasource property of Combobox to this dt.

there is New button, when user clicks on it, it simply clears all fields text, their DataBindings, for combox also i am using it as
cbBox.DataBinding.Clear();
cbBox.Text = "";

then there Save button which saves data to DB, on this Save click event i am checking data entered, like
if(cbBox.Text =="")//here it shows previous text if user do not enter any data
// after clicking New button (in debugging), but if user enter some data then that
//entered data
{
// related code
}

But here is problem, after clicking new button, all fields got clear, cbBox text goes blank. But if user did not enter any data in cbBox then it retains the previous text(text before clicking New button)

a) why this? how to rectify.


b)Related to DataRow?
when we load some data from DB, we fill it in Datatable obj first.
then iterate thru all rows.

SQL = "Select name from Data where ID = 23";
execute this SQL against DB.
assume ID is primary key,
now only single row returned,

How to get this DataRow without filling it in Datatable?

regards,