.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

counting total comment received on a particular topic and displayed it in the grid column

Posted By: Nabin     Posted Date: February 04, 2010    Points:2   Category :ASP.Net
Hi all
I am developing a site in which there is a article gallary and it allows the users to post their comment on a particular article.
So i want to count the comments for each article and show then in the admin section for just giving information to the admin that how many comment received on which article.

So can anyone help me on this topic and plz give me the detail code in C#

Responses
Author: Naresh             
Posted Date: February 04, 2010     Points: 5   

hi nabin,
Here is the code .(C#.net)

1. to count no of records in database

SqlConnection con = new SqlConnection("Server=LocalHost;DataBase=databasename;Uid=sa;Pwd=sa");
con.Open();
SqlCommand cmd1 = new SqlCommand("select count(Column_Name) from TableName", con);
int num1;
num1 = Convert.ToInt32(cmd1.ExecuteScalar());
this.TextBox1.Text = Convert.ToString(num1);
con.Close();


2. To display Record in DataGrid

SqlConnection con = new SqlConnection("Server=LocalHost;DataBase=databasename;Uid=sa;Pwd=sa");
con.Open();
SqlCommand cmd = new SqlCommand("select * from TableName", con);
DataSet ds1 = new DataSet();
SqlDataAdapter dd1 = new SqlDataAdapter(cmd);
dd1.Fill(ds1);
this.DataGrid1.DataSource = ds1;
this.DataGrid2.DataBind();
con.Close();

Thanks
Naresh
Author: Nabin             
Posted Date: February 04, 2010     Points: 5   

Thanks
Malathy




Regards
Nabin

Author: Lalij Mer             
Posted Date: February 04, 2010     Points: 5   

Try this link

http://dotnetslackers.com/articles/gridview/Optimized-Paging-and-Sorting-in-ASP-NET-GridView.aspx

Please Check my answer if you help....
Thank You...

Lalit.


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend