Click here to Skip to main content
15,905,563 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
hi can any one tel me how to bind total sum in textbox or in label in page load.??
thanks
Posted

try
{
string sql="select sum(att_name) from table_name";
sqlcommand cmd=new sqlcommnad(sql,connectionstring);
cmd.connection=connectionstring;
con.open();
sqldatareader dr=cmd.executereader();
if(dr.Read())
{
textbox1.text=dr[0].tostring();

}
dr.close();
conc.close();
}
 
Share this answer
 
Comments
ythisbug 2-Jun-12 1:08am    
thanks rushi i will try.thanks again
here is simple example

C#
protected void Page_Load(object sender, EventArgs e){

if (!IsPostBack)
        {
   // now u can use solution 1 to fill sum in textbox
}}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900