c# - Bind TextBox to DataAdapter -


.cs

    datatable dt;     npgsqldataadapter adapter;     npgsqlcommand selcmd, upcmd, delcmd, inscmd;     npgsqlconnection conn;     npgsqltransaction tran;      public void readandfill()     {         conn.open();         tran = conn.begintransaction();          selcmd.connection = conn;         selcmd.transaction = tran;          dt.clear();         adapter.fill(dt);         dgmain.itemssource = dt.defaultview;         tran.commit();         conn.close();     }     private void window_loaded(object sender, routedeventargs e)     {          readandfill();         datacontext = dt;         } 

.xaml

<datagrid x:name="dgmain" horizontalalignment="stretch" verticalalignment="stretch" grid.row="1" autogeneratecolumns="false"/> <textbox x:name="textbox" height="23" textwrapping="wrap" text="{binding name}" width="120"/> 

so can edit first row of datatable dt through textbox. , data in textbox not change when move on datagrid dgmain. how fix it?

in case, textbox should tied datagrid. have not found example of how textbox bind datatable / dataset / dataadapter , keep same logic: data in textbox changed moving on datagrid.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -