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
Post a Comment