Hi,
Here is a simple way to do what you are looking for
<script runat="server">
void Page_Load(objec t sender, EventArgs e)
{
if (!IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.Add( "FirstColumn",t ypeof(int));
dt.Columns.Add( "SecondColu mn", typeof(int));
DataRow dr = dt.NewRow();
dr["FirstColum n"]=34;
dr["SecondColu mn"]=12;
dt.Rows.Add(dr) ;
dr = dt.NewRow();
dr["FirstColum n"]=7;
dr["SecondColu mn"]=4;
dt.Rows.Add(dr) ;
grd.DataSource= dt;
grd.DataBind();
}
}
</script>
<asp:GridView runat="server" ID="grd" AutoGenerateCol umns="false">
<Columns>
<asp:BoundFie ld DataField="Firs tColumn" HeaderText="Fir st" />
<asp:BoundFie ld DataField="Seco ndColumn" HeaderText="Sec ond"
/>
<asp:TemplateFi eld HeaderText="Sum ">
<ItemTemplate >
<%# ((int)Eval("Fir stColumn"))
+((int)Eval("Se condColumn")) %>
</ItemTemplate>
</asp:TemplateFie ld>
</Columns>
</asp:GridView>
"Phillip Vong" wrote:
Newbie here trying to learn.
Using VS2005 / learning in VB.NET for an ASPX page.
Sorry for this simple question. I have a Gridview1 with 2 columns. I added
a 3rd column and all I want to do is add the numbers in the 1st and 2nd
column together for the 3rd column. Can someone tell me where I can put the
code in Visual Studio 2005 and how I tell the Gridview to do the simple
math?
Is there a site that will teach me exactly this? I googled but didn't find
exactly this.