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

Nested GridView cell value

15
We have a GridView2 in GridView1 EditTemplate.
And we have a button (commandname="Update") on GridView2.

When Button1 is clicked GridView1 goes into edit mode and displays GridView2.
Now when Button2 is Clicked, we want the cell[0] value of GridView2 to be displayed as Label1 Text on GridView1 and come out of the GridView1 edit mode.

Basically we want to capture gridView2 cell[0] value and display that on Label1 of GridView1.

We have written the below code. But we are unsure on how to grab GridView2.cell[0] value and display it as Label1 text.

Can someone please assist us with this?

Also, we are not sure if we can use rowupdated event for this. Please also guide us which events we should be using to achieve the functionality. Sample code would help us..

Thanks and much appreciated..


Expand|Select|Wrap|Line Numbers
  1. <asp:GridView ID="GridView1" runat="server" OnRowEditing="GridView1_RowEditing" Width="434px">
  2.   <Columns>
  3.        <asp:TemplateField>
  4.         <ItemTemplate>
  5.          <asp:Label ID="label1" runat="server" />
  6.          <asp:Button ID="Button1" CommandName="Edit" runat="server" Text="Button" />
  7.         </ItemTemplate>
  8. <EditItemTemplate>
  9.        <asp:GridView ID="GridView2" runat="server" OnRowUpdated="GridView2_RowUpdated">
  10.            <Columns>
  11.               <asp:TemplateField>
  12.               <ItemTemplate>
  13.                <asp:Button ID="Button2" CommandName="Update" runat="server" Text="Select" />
  14.                </ItemTemplate>
  15.             </asp:TemplateField>
  16.            </Columns>
  17.      </asp:GridView>
  18. </EditItemTemplate>
  19. </asp:TemplateField>
  20. </Columns>
  21. </asp:GridView>
  22.  


//GridView1 is binded in this method
Expand|Select|Wrap|Line Numbers
  1. public void ActivityDataBind()
  2. {
  3. GridView1.DataSource = dt;
  4. GridView1.DataBind();
  5. }
  6.  
//Child gridView binding in GridView1 Row Editing
Expand|Select|Wrap|Line Numbers
  1.  
  2. protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
  3.     {
  4.     try
  5.     {
  6.     GridView1.EditIndex =e.NewEditIndex;
  7.     ActivityDataBind();
  8.  
  9.     GridView gv=(GridView)(GridView1.Rows[e.NewEditIndex].Cells[0].FindControl("GridView2"));
  10.  
  11.     DataTable dt=new DataTable();
  12.     // All the databinding table stuff code goes here.....
  13.     gv.DataSource = dt;
  14.     gv.DataBind();
  15.     }
  16.     catch(Exception ei)
  17.     {
  18.     Response.Write(ei.Message.ToString());                
  19.     }
  20.  
  21.     }
  22.  
Mar 12 '10 #1
2 3737
Frinavale
9,735 Expert Mod 8TB
Did you try implementing a method that handles the GridView2's RowEditing event?

-Frinny
Mar 12 '10 #2
renuami
15
Yes.


protected void GridView2_RowEditing(object sender, GridViewEditEventArgs e)
{
}

At the first place when i type GridView2, it is not recognised by VS Intellisense.

Any idea??

I tried almost all the methods and no luck.

Please Advise...

Thanks
Mar 13 '10 #3

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

Similar topics

1
by: John_H | last post by:
Re: ASP.NET 2.0 I would like suggestions or code examples on how to collect a variable length list of input data (item# & item quantity specifically). I thought that I could accomplish this...
1
by: Jon S via DotNetMonster.com | last post by:
HI all, I'm returning a dataset to a gridview control. When the gridview asp.net control is populated from the returning dataset some of the cells remain empty. This is expected as some data...
0
by: Innova | last post by:
Hi, We are working on a gridview inside the gridview (parent-child) scenario. The data of child grid will depend on the data of parent. Objectives: 1.Add new row in parent grid after each row...
7
by: aljamala | last post by:
Hi, I was wondering if there is a way to make a single cell readonly within a GridView? I know you can do it for a column but what about a cell within that column? Thanks!
1
by: K B | last post by:
I would like to create a gridview as below: Project Name 1-1 1-2 1-3 1-4 1-5 1-6 Project 1 BLUE BLUE BLUE BLUE GREEN GREEN more projects I would like to fill the...
3
by: Bill Gower | last post by:
I have an cell which contains a field member which is filled with String.Empty. When I retrieve the value in the cell with Cells.Text.ToString() and try to compare it to String.Empty, I can't...
0
by: sharonrao123 | last post by:
hello all, I have a parent gridview company and in this one a nested gridview people, Is it possible to allow the user to select one row or multiple rows from the people gridview using a check box...
14
by: Mike | last post by:
I have a gridview that has a button in the last cell of each row. I want to get the text from cell 1 for that row the button was clicked on. So if my gridview looks like this: N-12 BMW ...
0
by: minhtran | last post by:
Hi everyone I have a problem when I want to edit the value from nested dropdownlist in Gridview, Please, anyone can help me to solve this problem, a great appreciation from me in advance. here is...
6
by: RobertTheProgrammer | last post by:
Hi folks, Here's a weird problem... I have a nested GridView setup (i.e. a GridView within a GridView), and within the nested GridView I have a DropDownList item which has the...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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...

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.