<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White"
BorderColor="#336699" BorderStyle="Solid" BorderWidth="1px" CellPadding="2" Font-Names="Verdana"
ShowFooter="true" Font-Size="10pt" Width="50%" GridLines="Horizontal"
OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="Date">
<ItemTemplate>
<asp:Label ID="lblPrice" runat="server" Text='<%# Eval("date")%>' />
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lblTotalPrice" runat="server" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="salary">
<ItemTemplate>
<asp:Label ID="lblUnitsInStock" runat="server" Text='<%# Eval("sal") %>' />
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lblTotalUnitsInStock" runat="server" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</FooterTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#336699" Font-Bold="True" ForeColor="White" HorizontalAlign="Left" />
<HeaderStyle BackColor="#336699" Font-Bold="True" ForeColor="White" HorizontalAlign="Left" />
</asp:GridView>
private void BindData()
{
SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;Initial Catalog=anil;Integrated Security=True");
string query = "SELECT * FROM anil";
SqlDataAdapter da = new SqlDataAdapter(query, con);
DataTable table = new DataTable();
da.Fill(table);
GridView1.DataSource = table;
GridView1.DataBind();
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;Initial Catalog=anil;Integrated Security=True");
if (e.Row.RowType == DataControlRowType.DataRow)
{
tsals += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "sal"));
}
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[1].Text = String.Format("{0:c}", tsals);
}
}
BorderColor="#336699" BorderStyle="Solid" BorderWidth="1px" CellPadding="2" Font-Names="Verdana"
ShowFooter="true" Font-Size="10pt" Width="50%" GridLines="Horizontal"
OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="Date">
<ItemTemplate>
<asp:Label ID="lblPrice" runat="server" Text='<%# Eval("date")%>' />
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lblTotalPrice" runat="server" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="salary">
<ItemTemplate>
<asp:Label ID="lblUnitsInStock" runat="server" Text='<%# Eval("sal") %>' />
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lblTotalUnitsInStock" runat="server" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</FooterTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#336699" Font-Bold="True" ForeColor="White" HorizontalAlign="Left" />
<HeaderStyle BackColor="#336699" Font-Bold="True" ForeColor="White" HorizontalAlign="Left" />
</asp:GridView>
private void BindData()
{
SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;Initial Catalog=anil;Integrated Security=True");
string query = "SELECT * FROM anil";
SqlDataAdapter da = new SqlDataAdapter(query, con);
DataTable table = new DataTable();
da.Fill(table);
GridView1.DataSource = table;
GridView1.DataBind();
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;Initial Catalog=anil;Integrated Security=True");
if (e.Row.RowType == DataControlRowType.DataRow)
{
tsals += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "sal"));
}
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[1].Text = String.Format("{0:c}", tsals);
}
}
No comments:
Post a Comment