Sunday, 15 June 2014

asp.net - How to Add File Upload Control in TableCell using C# -



asp.net - How to Add File Upload Control in TableCell using C# -

i creating grid view in code behind using tablecell , gridviewrow

the info fetched database table.

my code :

using system; using system.collections.generic; using system.linq; using system.web; using system.web.ui; using system.web.ui.webcontrols; using system.data; using system.data.sqlclient; public partial class gv1 : system.web.ui.page { sqlconnection cn; sqlcommand cmd; dataset ds; sqldataadapter da; protected void page_load(object sender, eventargs e) { cn = new sqlconnection("data source=amir-pc\\mohemmad;initial catalog=crm_investplus;integrated security=true"); } protected void button1_click(object sender, eventargs e) { cn.open(); cmd = new sqlcommand("select * customer_master", cn); da = new sqldataadapter(cmd); ds = new dataset(); da.fill(ds); cn.close(); gridview gr1 = new gridview(); table t = new table(); gr1.controls.add(t); (int = 0; < 6; i++) { gridviewrow row = new gridviewrow(i, i, datacontrolrowtype.datarow, datacontrolrowstate.normal); tablecell cell1 = new tablecell(); tablecell cell2 = new tablecell(); tablecell cell3 = new tablecell(); cell1.text = ds.tables[0].rows[i][0].tostring(); cell2.text = ds.tables[0].rows[i][1].tostring(); cell3.text = ds.tables[0].rows[i][2].tostring(); row.cells.add(cell1); row.cells.add(cell2); row.cells.add(cell3); gr1.controls[0].controls.addat(i, row); } form1.controls.add(gr1); } }

the gridview generated fine. problem display fileuploadcontrol in place of cell3(i.e. want place fileuploadcontrol in cell3)

please help..

thanks in advance...

try this:

fileupload fileupload = new fileupload(); cell3.controls.add(fileupload);

c# asp.net

No comments:

Post a Comment