Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 3976 | Replies: 14
![]() |
•
•
Join Date: Sep 2006
Posts: 105
Reputation:
Rep Power: 3
Solved Threads: 0
I have a datatable which is having n no. of rows and each row has a unique field say ID.
Now I want to get a particular row for a specified ID.
eg. there are 5 rows in a datatable and the id's are
1,2,3,4 and 5 and if I want to select a row having ID = 4
What will be the code snippet for that?
Does anybody have any idea?
Thanks in advance,
Now I want to get a particular row for a specified ID.
eg. there are 5 rows in a datatable and the id's are
1,2,3,4 and 5 and if I want to select a row having ID = 4
What will be the code snippet for that?
Does anybody have any idea?
Thanks in advance,
•
•
Join Date: Oct 2007
Location: Bristol, UK
Posts: 1,125
Reputation:
Rep Power: 4
Solved Threads: 48
You will need to modify your select statement. Are you using SQL table as your back end database?
If you have a quality, be proud of it and let it define you. Add it to the world!
If you got your answer, please mark the thread as Solved. It saves time when people are looking to contribute threads or for answers!
If you got your answer, please mark the thread as Solved. It saves time when people are looking to contribute threads or for answers!
•
•
Join Date: Sep 2006
Posts: 105
Reputation:
Rep Power: 3
Solved Threads: 0
Actually what I m trying to do is I m firing a query in SQL Server 2005 to retrieve records for selected criteria.
Based on the selection the query result I m taking that in a datatable and I have a GridView where this list of results is displayed.
Now there is a hyperlink in the Grid to select the detailed information about a particular result.
eg. In the query result I get 5 records matching the selection criteria, which are stored in a datatable.
now these reults are displayed in the grid and when i click on the hyperlink of a particular row then the records of that row should get selected and the detailed info should get displayed in another page.
For this particular row selection I want a row from the datatable.
Based on the selection the query result I m taking that in a datatable and I have a GridView where this list of results is displayed.
Now there is a hyperlink in the Grid to select the detailed information about a particular result.
eg. In the query result I get 5 records matching the selection criteria, which are stored in a datatable.
now these reults are displayed in the grid and when i click on the hyperlink of a particular row then the records of that row should get selected and the detailed info should get displayed in another page.
For this particular row selection I want a row from the datatable.
•
•
Join Date: May 2008
Posts: 47
Reputation:
Rep Power: 1
Solved Threads: 1
Hi Bhavna. Hw do u do?
Well, first of all I would like to repeat what you've asked so that it'll be, you know, better for me to give my view...
You are trying to select records of a particular field from a datatable displayed in a grid, through a hyperlink and also the datatable is previously populated using a select query from a SQL Server 2005 and the data are displayed in a grid,aren't you?
In this context, I would like to say that when you click the hyperlink a sub routine should be executed wherein you provide another select query which selects data from the datatable on the basis of the clicked field. Moreover, in the grid itself you can have the cell address. Why not you try using those cell addresses so that you can display records of tyhe particular field you wanted.
Hope my views help you.
Well, first of all I would like to repeat what you've asked so that it'll be, you know, better for me to give my view...
You are trying to select records of a particular field from a datatable displayed in a grid, through a hyperlink and also the datatable is previously populated using a select query from a SQL Server 2005 and the data are displayed in a grid,aren't you?
In this context, I would like to say that when you click the hyperlink a sub routine should be executed wherein you provide another select query which selects data from the datatable on the basis of the clicked field. Moreover, in the grid itself you can have the cell address. Why not you try using those cell addresses so that you can display records of tyhe particular field you wanted.
Hope my views help you.
•
•
Join Date: May 2008
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 1
hi sis,
i give the code here
for asp page
i print the name in lables name as first and last
just copy and run it
i give the code here
for asp page
ASP Syntax (Toggle Plain Text)
<asp:GridView DataKeyNames="nameid" OnRowCommand="list" ID="grid1" AutoGenerateColumns="false" runat="server" > <Columns> <asp:BoundField DataField="nameperson" HeaderText="firstname" /> <asp:BoundField DataField="lastnameperson" HeaderText="lastname" /> <asp:ButtonField ButtonType="Button" CommandName="list" HeaderText="list" /> </Columns> </asp:GridView> this is for asp.cs page protected void list(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "list") { int rowindex = Convert.ToInt32(e.CommandArgument); GridViewRow selectedrow = grid1.Rows[rowindex]; int key = Convert.ToInt32(grid1.DataKeys[selectedrow.RowIndex].Value); SqlConnection con = new SqlConnection("Server=BDL-111\\BDLSQL2000;User id=sa;Password=Sqladmin;DataBase=Training;"); con.Open(); SqlCommand cmd = new SqlCommand("select *from dani where nameid=" + key + "", con); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { first.Text = Convert.ToString(dr.GetString(1)); last.Text = Convert.ToString(dr.GetString(2)); } } }
just copy and run it
Last edited by peter_budo : May 11th, 2008 at 6:12 am. Reason: Keep It Organized - please use [code] tags
•
•
Join Date: Sep 2006
Posts: 105
Reputation:
Rep Power: 3
Solved Threads: 0
•
•
•
•
Hi Bhavna. Hw do u do?
Well, first of all I would like to repeat what you've asked so that it'll be, you know, better for me to give my view...
You are trying to select records of a particular field from a datatable displayed in a grid, through a hyperlink and also the datatable is previously populated using a select query from a SQL Server 2005 and the data are displayed in a grid,aren't you?
In this context, I would like to say that when you click the hyperlink a sub routine should be executed wherein you provide another select query which selects data from the datatable on the basis of the clicked field. Moreover, in the grid itself you can have the cell address. Why not you try using those cell addresses so that you can display records of tyhe particular field you wanted.
Hope my views help you.
After that should I get all the details that I got from the query output datatable?
since I m showing only 4-5 fields from datatable in GridView and all the details say 50 fields are shown after the clicking of hyperlink i.e. in another page
•
•
Join Date: Jun 2008
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
I have a datatable which is having n no. of rows and each row has a unique field say ID.
Now I want to get a particular row for a specified ID.
eg. there are 5 rows in a datatable and the id's are
1,2,3,4 and 5 and if I want to select a row having ID = 4
What will be the code snippet for that?
Does anybody have any idea?
Thanks in advance,
hewy bhavna...
me too having same problem like yours...
now do u have the solution for ur problem??if yes then pl let me know..
thnks
•
•
Join Date: Jun 2008
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
Actually what I m trying to do is I m firing a query in SQL Server 2005 to retrieve records for selected criteria.
Based on the selection the query result I m taking that in a datatable and I have a GridView where this list of results is displayed.
Now there is a hyperlink in the Grid to select the detailed information about a particular result.
eg. In the query result I get 5 records matching the selection criteria, which are stored in a datatable.
now these reults are displayed in the grid and when i click on the hyperlink of a particular row then the records of that row should get selected and the detailed info should get displayed in another page.
For this particular row selection I want a row from the datatable.
hey bhavna...
me too having same problem like yours...
now do u have the solution for ur problem??if yes then pl let me know..
thnks
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)






Linear Mode