473,408 Members | 1,784 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,408 software developers and data experts.

lookup page with a datagrid

112 100+
Hello,

I need help creating a lookup page which has a datagrid view.
My firstpage.aspx has a textbox and button. When the button is clicked, it would open a pop-up page with a datagrid which has 2 columns in it. The user can select a row and the selected row's text should appear in the textbox of firstpage.aspx.

I tried using javascript but unable to retrieve the value of the selected row. So can somebody help. I am using asp.net and C#.

Thanks in advance.
Dec 11 '09 #1
8 1962
sanjib65
102 100+
Please go through the link below

http://http://msdn.microsoft.com/en-.../ms178139.aspx

What you'd like to do can be done through PreviousPage property.
Dec 12 '09 #2
user1980
112 100+
thank you sanjib for the response. i will look into it.
Dec 15 '09 #3
Frinavale
9,735 Expert Mod 8TB
You should be doing this using JavaScript (have to really).
Why were you unable to retrieve the selected row?
What did you try?

-Frinny
Dec 15 '09 #4
user1980
112 100+
hello...i did go through the msdn link but am unable to use the findcontrol for my data grid.

Frinny
I was not able to get the GridView.SelectedRow.Cells[1].Text value into my javascript. i can select the value and display it in the same page but do not know how can I pass that value to my javascript. I have a working javascript that would transfer the value to the first page. but passing the value of selected text is my problem.

Expand|Select|Wrap|Line Numbers
  1.  function selectcode(code) {
  2.          if (window.opener && !window.opener.closed)
  3.          window.opener.document.form2.textbx.value = code;
  4.          window.close();
  5.          }
this code now writes 'code' in my textbox, instead it should write the selected code say 1234 into my textbox.
this is my gridview code
Expand|Select|Wrap|Line Numbers
  1. <asp:GridView ID="GridView" runat="server" AutoGenerateColumns="False" 
  2.      onselectedindexchanged="GridView_SelectedIndexChanged">
  3.      <Columns>
  4.       <asp:CommandField ShowSelectButton="True" />
  5.       <asp:BoundField DataField="Code" HeaderText="Code" SortExpression="Code" />
  6.       <asp:BoundField DataField= "Name" HeaderText="Name" SortExpression="Name" />
  7.      </Columns>
  8.  
  9.  </asp:GridView> 
i am unable to put my javascript in the code to retrieve the value of selected row.
Please let me know if I am not clear. Thanks in advance.
Dec 15 '09 #5
Frinavale
9,735 Expert Mod 8TB
I Just posted a solution like this in another thread a day or so ago.
Check out the JavaScript function I posted here:
http://bytes.com/topic/asp-net/answe...ew#post3529043....

-Frinny
Dec 15 '09 #6
user1980
112 100+
sorry, I am unable to figure out the solution for my problem using the javascript in that solution.
I am using this code but no results
Expand|Select|Wrap|Line Numbers
  1. <asp:TemplateField HeaderText="Name">
  2.                     <ItemTemplate>
  3.                        <a style="cursor: hand" onmouseover="this.style.textDecoration='underline'" onmouseout="this.style.textDecoration='none'"
  4.                             name="Name" runat="server" onclick="javascript:selectcode(this)"
  5.                             id="Name">
  6.         <%# DataBinder.Eval(Container.DataItem, "Name") %>
  7.                         </a>
  8.         </ItemTemplate>
  9.                    </asp:TemplateField>
Dec 15 '09 #7
Frinavale
9,735 Expert Mod 8TB
You could probably get a reference to the row using the element that is used to select the row.

Right now you're passing that element to the "selectcode" method.

Expand|Select|Wrap|Line Numbers
  1. function selectcode(elementUsedToSelectRow)
  2. {
  3. }
From here you need to retrieve the row. The row is a parent element of the element used to select the row...in fact it's the parent element of the parent element. You need to get a reference to the row that the element belongs to though so that you can loop through the cells and grab the information you need.

I've moved this thread to the JavaScript forum.
I think that they'll have a better idea how to do this than I do.

-Frinny
Dec 15 '09 #8
user1980
112 100+
thank you for the reply.

found the solution. i have to use #Eval('Name') to get the selected row index and that can be passed to javascript.
Dec 15 '09 #9

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

Similar topics

0
by: Al | last post by:
hi I have a Datagrid where I click on the id to open another aspx page to edit the selected record. I was able to pass the selected row's id and use it in the second page to pull the record into...
4
by: Vik | last post by:
How can I display the lookup values in a datagrid? E.g., the datagrid displays a table that contains a ProductID field. I want to display a Product description from a Product table in that...
1
by: Big Dave | last post by:
Good morning. This group has been a great help so far, and it is much appreciated. Here's my new question. I want to be able to create a datagrid at runtime, which will have template columns...
1
by: Demetri | last post by:
Hello, I have a page with a datagrid. The datagrid has a column called Employee Name. This column is for display purposes. However, in edit mode (including making additions) the user will need...
2
by: abc my vclass | last post by:
I want to write a form control to lookup some tables fields from database, let users to select one record (or multi-select more records) under win-form environment for fill some fields of parent...
0
by: dbuchanan | last post by:
Hello, For my datagrid I added a datagrid table style to include columns from my lookup tables. These display the values in the lookup tables rather than just the integer key value stored in the...
3
by: dbuchanan | last post by:
Hello, (Windows forms - SQL Server) I fill my datagrid with a stored procedure that includes relationships to lookup tables so that users can see the values of the combobox selections rather...
0
by: JohnSouth | last post by:
Hi I need a dropdown list column in a datagrid control, and I've got the basics working where the column contents is text. However the data table stores a foreign key to a lookup table so I need...
1
by: tommy.tashjian | last post by:
Hi, I have a datagrid with a textbox column that needs a lookup table. Now, I was going to just use a dropdownlist instead of the textbox, but that won't fly here. So, what I need to know, is it...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.