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

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

displaying names

Posted By: Rama Krishna     Posted Date: August 19, 2009    Points:2   Category :C#
hai akhil,syedshakir hussain
trying with your code i didn't get it.so please give complete code with given new details
in first page of my project i want to design a page,the page
design is like whenever we clicks on compose button in gmail.it displays a form
my requirement is whenever page is loaded,i want to display all the contactnames separated by commas,by calling the values from table 'Employees'and column name is 'FirstName'and database is 'Northwind' or calling values from stored procedure'getcontactrecords'
what code is suitable under page load event (i want C#.net code)
could anyone send the complete code snippet?
this is my code
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page

protected void Page_Load(object sender, EventArgs e)
DataTable Employees = new DataTable();
String str = "TxtTO.Text";
foreach (DataRow row in Employees.Rows)
str = str + ((row["column_FirstName"] == DBNull.Value) ? "" : row["column_FirstName"].ToString() + ",");
if (str.Length > 0)
str = str.Remove(str.Length - 1, 1);

Author: Syed Shakeer Hussain             
Posted Date: August 19, 2009     Points: 5   

Hi Rama Krishna,
use the Below code.It is 100% working.
SqlCommand cmd = new SqlCommand("select FirstName from Employees", conn);
SqlDataReader dr = cmd.ExecuteReader();
string str = "";
string com = ",";
while (dr.Read())
str = dr["name"] + com + str;

if you want to dispaly it in a Textbox then write below code after the while loop.

Author: Rama Krishna             
Posted Date: August 20, 2009     Points: 5   

thank you very much syed shakeer hussain,akhil raj
after 5 days i got solution to my problem using data reader concept

Author: Syed Shakeer Hussain             
Posted Date: August 21, 2009     Points: 5   

Hi Rama!
Above code is send by me,Then why you are giving complimets to Akhil Raj!
Dont take serious,just joking

Author: Rama Krishna             
Posted Date: August 21, 2009     Points: 5   

akhil was also gived some clues,thatswhy i added him,but 80% credit goes to you only

Author: Akhil Raj       [Moderator]      
Posted Date: August 22, 2009     Points: 5   

nice to heard that you got the answer rama. hi syed you only got 80% dont worry ha ha.. i don't like to give full code to user because otherwise only they try something...and got the correct idea from their own mind.

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

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