•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 329,727 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,540 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 179 | Replies: 6
![]() |
•
•
Join Date: Sep 2006
Posts: 93
Reputation:
Rep Power: 2
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: 919
Reputation:
Rep Power: 2
Solved Threads: 30
•
•
Join Date: Sep 2006
Posts: 93
Reputation:
Rep Power: 2
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: 17
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: 0
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 : 1 Day Ago at 5:12 am. Reason: Keep It Organized - please use [code] tags
•
•
Join Date: Sep 2006
Posts: 93
Reputation:
Rep Power: 2
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
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
DaniWeb Marketplace (Sponsored Links)
Other Threads in the ASP.NET Forum
- Previous Thread: split string to table
- Next Thread: table control


Linear Mode