hi......
i m new devloper in c# so i need to know how to write to populate data in the gridview from sql server......and we are using multiview .......plz reply soon i really mean it thanks in advance..bye

Please do not PM me asking for help, it is not terribly polite and is poor etiquette.
With regards to your question what data do you want to populate grid with? SQL database for example?

i m new devloper

Ok the absolute number one thing a newbie needs to know:

http://catb.org/~esr/faqs/smart-questions.html#intro

how to write to populate data in the gridview from sql server

Well how long is a bit of string?

There are *many* ways to accomplish this in the .NET framework. You need to be more specific (see my earlier link) Also, there are 1000's of tutorials and articles and books all explaining this that we took the time to read to become developers why shouldn't you? When you have, then come back with some code you have tried and we can help with any specific errors or better ways to do it.

To help you get started you need to look at SqlDataSource and ADO.NET.

Good luck.

a link on that page may be of use

I like the article hollystyles!

hey can u answer me how to delete the rows means if u use any mail browser then u know that they provide u an chekbox in each row and the box u tick and then u press delete button then all rows that were click will be deleted .....whats the code for this?

hey thanks for ur such a nice suggesions and ya i trid some codes but was not much clear so ask.......nothing else...fine thnxs...ok.bye

Sigh....

Search hint: TemplateColumn, GridView.Items collection.

ya i trid some codes

Great !!

Post it, then we stand a chance of helping you straighten it out.

hey can u answer me how to delete the rows means if u use any mail browser then u know that they provide u an chekbox in each row and the box u tick and then u press delete button then all rows that were click will be deleted .....whats the code for this?

dataset retriving

using System;
using System.Data;
using System.Data.SqlClient;
namespace PopulateDataSet {
/// <summary>
/// Summary description for Class1.
/// </summary> class Class1
{
static void Main(string[] args)
{
string sConnectionString; sConnectionString = "Password=myPassword;User ID=myUserID;" + "Initial Catalog=pubs;" + "Data Source=(local)";
SqlConnection objConn = new SqlConnection(sConnectionString);
objConn.Open();
SqlDataAdapter daAuthors = new SqlDataAdapter("Select * From Authors", objConn);
DataSet dsPubs = new DataSet("Pubs");
daAuthors.FillSchema(dsPubs,SchemaType.Source, "Authors");
daAuthors.Fill(dsPubs,"Authors");
DataTable tblAuthors;
tblAuthors = dsPubs.Tables["Authors"];
foreach (DataRow drCurrent in tblAuthors.Rows)
{
Console.WriteLine("{0} {1}", drCurrent["au_fname"].ToString(), drCurrent["au_lname"].ToString());
}
Console.ReadLine();
}
}
}

hey can u answer me how to delete the rows means if u use any mail browser then u know that they provide u an chekbox in each row and the box u tick and then u press delete button then all rows that were click will be deleted .....whats the code for this?

1. You can't do check boxes in a console app.

2. Please use [ code ] tags when posting code it's the law here.

3. to delete you want a SqlCommand object

String strAuthorid = Console.ReadLine();
try
{
int authorid = Convert.ToInt32(strAuthorId);

string sConnectionString = "Password=myPassword;User ID=myUserID;Initial Catalog=pubs;Data Source=(local)";

SqlConnection objConn = new SqlConnection(sConnectionString);
objConn.Open(); 

SqlCommand cmd = objConn.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "Delete from Authors where auid=@authorid";
cmd.Parameters.Add("@authorid", authorid)

int recordsAffected = cmd.ExecuteNonQuery();

if recordsAffected == 0)
      throw new ApplicationException("Invalid authorid");
}catch(Exception)
{
          Console.WriteLine("Please enter a valid author id.");
}
finally
{
          if(objConn != null)
         {
                  if(objConn.State == ConnectionState.Open)
                              objConn.Close();
 
                  objConn.Dispose();
         }
}

//Thoses directories are obligatory to include
using System.Data;
using System.Data.SqlClient;
//Instantiate a new sql connection
SqlConnection oConnection = new SqlConnection();
//Add a connection string to your conection
oConnection.ConnectionString = "Data Source= /*put your server name here*/; Initial Catalog=/*Put your data base name here*/; Integrated Security=true";
//Add an sql command and set the query and the connection
SqlCommand oCommand = new SqlCommand(/*put your sql query here*/,oConnection);
//The adapter has as mission populate a table or a data set with data
SqlDataAdapter oAdapter = new SqlDataAdapter(oCommand);
DataTable oTable = new DataTable();
//populate data
oAdapter.Fill(oTable);
//populate your data grid view with data from the oTable data table
oDataGridView.DataSource = oTable;
oDataGridView.DataMember = oTable.TableName;

//Those directives are necessary
using System.Data;
using System.Data.SqlClient

//Instantiate a new sql connection
SqlConnection oConnection = new SqlConnection();
//Add a connection string to your conection
oConnection.ConnectionString = "Data Source= /*put your server name here*/; Initial Catalog=/*Put your data base name here*/; Integrated Security=true";
//Add an sql command and set the query and the connection
SqlCommand oCommand = new SqlCommand(/*put your sql query here*/,oConnection);
//The adapter has as mission populate a table or a data set with data
SqlDataAdapter oAdapter = new SqlDataAdapter(oCommand);
DataTable oTable = new DataTable();
//populate data
oAdapter.Fill(oTable);
//populate your data grid view with data from the oTable data table
oDataGridView.DataSource = oTable;
oDataGridView.DataMember = oTable.TableName;

Please use code tags when posting code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.