SqlConnection con = new SqlConnection();
con.ConnectionString = WebConfigurationManager.ConnectionStrings["SQLCon"].ToString();
con.Open();
SqlDataAdapter da = new SqlDataAdapter("SELECT date,value,value2 from chartsample", con);
DataTable dt = new DataTable();
da.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
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 .
sonali thaku...
Member
2 Points
30 Posts
binding the data to textbox or (image) as filled with data of columnvalue in gridview.
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">
<Columns>
<asp:BoundField HeaderText="UserName" DataField="date"/>
<asp:BoundField HeaderText="LastName" DataField="value" />
<asp:TemplateField>
<ItemTemplate>
<asp:TextBox ID="txtValue" Width="200px" runat="server" BackColor="Blue" Text='<%# Eval("value2") %>' ></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
code behind:
SqlConnection con = new SqlConnection();
con.ConnectionString = WebConfigurationManager.ConnectionStrings["SQLCon"].ToString();
con.Open();
SqlDataAdapter da = new SqlDataAdapter("SELECT date,value,value2 from chartsample", con);
DataTable dt = new DataTable();
da.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
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
Curt_C
All-Star
66017 Points
7639 Posts
Moderator
Re: binding the data to textbox or (image) as filled with data of columnvalue in gridview.
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.
v5.1 of iTracker (Inventory Tracker Starter Kit) is out, Download it now!
sonali thaku...
Member
2 Points
30 Posts
Re: binding the data to textbox or (image) as filled with data of columnvalue in gridview.
Jan 10, 2013 05:24 PM|LINK
Hello,
it should bind dynamically as we are binding from databse.how could we make it as 80 or some thing else.
:(
any other solutions
Curt_C
All-Star
66017 Points
7639 Posts
Moderator
Re: binding the data to textbox or (image) as filled with data of columnvalue in gridview.
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
v5.1 of iTracker (Inventory Tracker Starter Kit) is out, Download it now!