How to pass data from local variable to datagridview using c# -
how pass value of calculated result in datagridview. in following code filled 2 columns of grid values fetched database through datatable, add new column named "text". want pass value of calculated hash in column there may b syntax problem or mistake causes error occurred. following code;
sqldataadapter sda = new sqldataadapter("select image,hash userinput pincode = '" + txt_lpin.text + "'",conn); datatable dt = new datatable(); sda.fill(dt); datagridview1.datasource = dt; int nor = datagridview1.rows.count; if (nor == 5) { logincluepoint lcp = new logincluepoint(); lcp.dgv_lcp.autosizecolumnsmode = datagridviewautosizecolumnsmode.fill; lcp.dgv_lcp.rowtemplate.height = 101; lcp.dgv_lcp.datasource = dt; datagridviewcolumn col = new datagridviewtextboxcolumn(); col.headertext = "text"; int colindex = lcp.dgv_lcp.columns.add(col); lcp.dgv_lcp.columns[2].visible = false; }
this problem resolved following code
datagridviewcolumn col = new datagridviewtextboxcolumn(); col.headertext = "text"; int colindex = lcp.dgv_lcp.columns.add(col); dgv_lcp.rows[0].cells[2].value = hash lcp.dgv_lcp.columns[2].visible = false;
Comments
Post a Comment