design the table and send the code.
please help me
Datagrid example using csharp
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Mar 14, 2012, 8:52 AM EDT
If you want to display records in a datagrid from database use below code.
using System.Data;
using System.Data.SqlClient;
SqlConnection con=new SqlConnection();
SqlCommand com;
SqlDataAdapter sqlda;
DataSet ds;
string str;
private void btnload_Click(object sender, System.EventArgs e)
{
con.Open();
str="select * from student";
com=new SqlCommand(str,con);
sqlda=new SqlDataAdapter(com);
ds=new DataSet();
sqlda.Fill(ds,"student");
dataGrid1.DataSource=ds;
dataGrid1.DataMember=("student");
con.Close();
}
Thanks
SenthilkumarRank #387 · 6.5K reputationPosted Mar 16, 2012, 8:52 PM EDT
select the appropriate database in sql server and create the below table.
CREATE TABLE Employees
(
iEmployeeID INT INDENTITY(1,1) PRIMARY KEY
,Name VARCHAR(100) NOT NULL
,Address VARCHAR(100) NOT NULL
,City VARCHAR(100) NOT NULL
,State VARCHAR(100) NOT NULL
,Country VARCHAR(100) NOT NULL
,Email VARCHAR(100) NOT NULL
,Mobile VARCHAR(100) NOT NULL
)
GO
Insert some rows for testing.
Place code asp:gridview control in your page and write the logic to load the data from the database. See the above post to get the results.
When you mention autogeneratecoulmns is tru then it will render the table as database table.