.net - Adding color to a table cell using C# -
i creating table , adding cells contents through c sharp code. code given below:
//creating table table table1 = new table(); table1.id = "table1"; table1.borderstyle = borderstyle.dashed; table1.gridlines = gridlines.both; this.controls.add(table1); //adding first row tablerow row1 = new tablerow(); //adding first cell tablecell cell1 = new tablecell(); //adding label label text1 = new label(); text1.text = "sourav ganguly"; cell1.controls.add(text1); row1.controls.add(cell1); table1.controls.add(row1); //adding second cell tablecell cell2 = new tablecell(); //adding label label text2 = new label(); text2.text = "rahul dravid"; cell2.controls.add(text2); row1.controls.add(cell2); //adding third cell tablecell cell3 = new tablecell(); //adding label label text3 = new label(); text3.text = "sachin tendulkar"; cell3.controls.add(text3); row1.controls.add(cell3); //adding second row tablerow row2=new tablerow(); //adding first cell tablecell cell4 = new tablecell(); //adding label label text4 = new label(); text4.text = "virender shewag"; cell4.controls.add(text4); row2.controls.add(cell4); table1.controls.add(row2); //adding second cell tablecell cell5 = new tablecell(); //adding label label text5 = new label(); text5.text = "ms dhoni"; cell5.controls.add(text5); row2.controls.add(cell5); table1.controls.add(row2); //adding third cell tablecell cell6 = new tablecell(); //adding label label text6 = new label(); text6.text = "zaheer khan"; cell6.controls.add(text6); row2.controls.add(cell6); table1.controls.add(row2);
i wish add background color each cell. possible create this? i.e in first cell of first row, wish add red color 50% of cell. wish cell remain colorless (usual white color) remaining 50%. similarly, second cell of first row, wish add yellow color 80% of cell , want remaining 20% of cell in default white color. is possible achieve such kind of functionality functionality using c#?
not exactly, can try replicate behavior setting text property following:
<div style="width:100px;height:20px"> <div style="background-color:red;width:80%;height:20px"/> <div style="float:left">hello</div> </div>
of course, you'll want replace hard-coded dimensions , color.
Comments
Post a Comment