Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 10, 2013 06:52 PM by Curt_C
Jan 10, 2013 05:12 PM|LINK
i need to bind the data of column value to textbox or imagebutton (to represent as a bar) in column of gridview using template field.
i have the data as:
databasename used(mb) total(mb) free() graph(as bar)
dbmonitor 80 100 20 textbox(need to be binded with the value of used)but as filled color
the code i have used as:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
<asp:BoundField HeaderText="UserName" DataField="date"/>
<asp:BoundField HeaderText="LastName" DataField="value" />
<asp:TextBox ID="txtValue" Width="200px" runat="server" BackColor="Blue" Text='<%# Eval("value2") %>'
SqlConnection con = new SqlConnection();
con.ConnectionString = WebConfigurationManager.ConnectionStrings["SQLCon"].ToString();
SqlDataAdapter da = new SqlDataAdapter("SELECT date,value,value2 from chartsample", con);
DataTable dt = new DataTable();
GridView1.DataSource = dt;
problem: am getting the value of column(ie used) as 80 in a textbox,
requirement is the value should be filled with color it should not show the value instead value should be filled
(80) in a total .
i think need to change the eval method
simply to say as bar.
how to achieve it,,
please help me out
Jan 10, 2013 05:20 PM|LINK
What I've done in the past is create a 1px image and then display it (in this case) 80 times. This gives you the appearance of a size bar.
Jan 10, 2013 05:24 PM|LINK
it should bind dynamically as we are binding from databse.how could we make it as 80 or some thing else.
any other solutions
Jan 10, 2013 06:52 PM|LINK
then use 2 DIV's. The first at 100% and the inner DIV set to use a red background and a width of 80%
That would be bindable and appear to be a bar