c# 4.0 - showing ListView error -


am not able insert update delete , clear operatopns on listview in winforms

here's code:

private void form1_load(object sender, eventargs e)     {         showdata();     }     private void showdata()     {         sqlconnection con = new sqlconnection("user id=sa;password=sql@123;database=arvind;server=ashok-pc");         con.open();         sqlcommand cmd = new sqlcommand("select * login_1",con);         datatable dt = new datatable();         sqldataadapter da = new sqldataadapter(cmd);         da.fill(dt);         listview1.datacontext = dt.defaultview;     } 

i got error in datacontext

system.windows.forms.listview not contain definition datacontext , no extension method accepting first argument of type system.windows.forms.listview found. 

you appear trying follow code example made wpf when you're using windows forms. winforms listview indeed not have such property , in fact doesn;t support data-binding.

do favour , use datagridview. assign datatable datasource property. binding defaultview pointless.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -