473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to bind datagrid

Hi All


Plz give me code how to bind datagrid with dataset. And one thing more i want that is i want to submit Roll No . at enquiry.aspx page and now after click on submit i want to redirect that page to result.aspx page. and in this page i want all the information about perticular candidate. so how it will do. plz guide me.


Regards
Kuldeep singh sethi
Oct 31 '06 #1
4 3843
store the roll number in some session variable
session["RollNo"]=rollno;
if the dataset is populating from database then make the following code

SqlConnection conn = new SqlConnection();
conn.ConnectionString = "integrated security=SSPI;SERVER=Your ServerNAME;DATABASE=Your Database Name;Connect Timeout=2;";
string cmdtext = "select * from TABLE NAME where ROLLNUMBER(your table field name)='"+session["RollNo"].toString()+"'";
conn.Open();
SqlCommand cmd = new SqlCommand(cmdtext, conn);
DataSet ds = new DataSet();
SqlDataAdapter sar = new SqlDataAdapter();
sar.SelectCommand = cmd;
sar.Fill(ds);

DataGrid1.DataSource = ds;
DataGrid1.DataBind();

if you want to do it visually

right click the smart tag of datagrid
choose datasourse as new datasource;
select database from the datasource configuration wizard.
click new connection button .
from the add connection window select servername and select windows authentication.
choose the database name and click ok.
then from the datasource configuration wizard click next.
select the radiobutton specify columns from a table or view.check the fields you want.and the click the where button.
from the add where clause window select the field name of your table eg.rollno;
select the source dropdownlist as session.
give the session name in the session field;
click ok;
Nov 1 '06 #2
store the roll number in some session variable
session["RollNo"]=rollno;
if the dataset is populating from database then make the following code

SqlConnection conn = new SqlConnection();
conn.ConnectionString = "integrated security=SSPI;SERVER=Your ServerNAME;DATABASE=Your Database Name;Connect Timeout=2;";
string cmdtext = "select * from TABLE NAME where ROLLNUMBER(your table field name)='"+session["RollNo"].toString()+"'";
conn.Open();
SqlCommand cmd = new SqlCommand(cmdtext, conn);
DataSet ds = new DataSet();
SqlDataAdapter sar = new SqlDataAdapter();
sar.SelectCommand = cmd;
sar.Fill(ds);

DataGrid1.DataSource = ds;
DataGrid1.DataBind();

if you want to do it visually

right click the smart tag of datagrid
choose datasourse as new datasource;
select database from the datasource configuration wizard.
click new connection button .
from the add connection window select servername and select windows authentication.
choose the database name and click ok.
then from the datasource configuration wizard click next.
select the radiobutton specify columns from a table or view.check the fields you want.and the click the where button.
from the add where clause window select the field name of your table eg.rollno;
select the source dropdownlist as session.
give the session name in the session field;
click ok;

Thanks a lot

Sir i am handling one another problem. I have installed .net 2003 and sqlserver 2000. Now i have made a login page. and also i have make a table in sqlserver.
but when i am running the application and putting username and password in the login fields then instead of going to Index.aspx page it shows a error "login failed for user 'Welcome\ IUSR ' " and show highlighted this line which is "Objcon.open();". So Plz help me for it


Regards

Kuldeep singh sethi
Nov 1 '06 #3
I think the problem is in your sql server authentication.
if you had a userid and password for sqlserver specify that in the connection string as userid="Your userid" password="Your Password"
otherwise use the same connection string and check the database name and servername;
Nov 2 '06 #4
I think the problem is in your sql server authentication.
if you had a userid and password for sqlserver specify that in the connection string as userid="Your userid" password="Your Password"
otherwise use the same connection string and check the database name and servername;


Thanks a lot to help me

keep in touch allways

kuldeep singh sethi
Nov 2 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Pete Nelson | last post by:
Does anyone know of a way to bind a string collection to a datagrid? Basically, I have an object, CreditPlans, and a string collection, ModelNumbers. I'd like to bind the ModelNumbers collection...
2
by: Vijaya | last post by:
Can we bind data to textbox in a headertemplate in a template column of a datagrid? If so please give some code snippets. Thank you
4
by: Greg Linwood | last post by:
I am wondering what the best approach to binding XML data to an asp:Table from the Page_Load event in a code behind module? I'm using VB.Net and initially approached this by adding a table to the...
6
by: coleenholley | last post by:
I have a Class Module written in VB that calls an RPC (written in COBOL) we have written code to read the data from the RPC, and we create a temporary datatable to store the data from the RPC. This...
3
by: AFN | last post by:
I need to manually create the data to be shown in a datagrid (or some data table object). Should I create an array and bind the array to the datagrid OR should I create a temporary dataset and...
1
by: suresh_C# | last post by:
Hi All, I want to bind datagrid with 3 different datatables. Please tell me what is a right way of doing that. Any help will be appreciated. Thanks, Mahesh
2
by: A Traveler | last post by:
Hi, I have a custom collection class i wrote, LineItemsCollection, which is a strongly typed collection of objects of my LineItem class. The LineItem class is a simple class with just a couple...
7
by: Jed | last post by:
I have a web service method that returns an array of custom objects marked serializeable with fully described public properties. When I bind the results to a DataGrid I can access the properties...
17
by: A_PK | last post by:
I have problem databinding the DataGrid with DataView/DataSet after the filter... I create the following proceudre in order for user to filter as many as they want, but the following code is only...
3
by: serge calderara | last post by:
Dear all, Does anyone know how to bind a System.Collection.ArraysList object to a Dataset ? Thanks for your reply Regards Serge
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.