473,583 Members | 2,875 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

multiple selection in nested gridview, help please

4 New Member
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 and also get the datakey (in my case personid) of the the rows selected. Please point me in the right direction. This is what i have so far but i have problem accessing the child gridview in the button click event

Cheers, Shilpa.

<asp:GridView ID="grdCompanyP eople" runat="server" AutoGenerateCol umns="False" DataKeyNames ="CoDetailID,Co ID" OnRowDataBound ="grdCompanyPeo ple_RowDataBoun d" SelectedIndex ="0" OnSelectedIndex Changing ="grdCompanyPeo ple_SelectedInd exChanging" OnRowCreated="g rdCompanyPeople _RowCreated" OnRowCommand ="grdCompanyPeo ple_RowCommand" OnPageIndexChan ging ="grdCompanyPeo ple_PageIndexCh anging" PageSize ="2" AllowPaging="Tr ue" OnSelectedIndex Changed ="grdCompanyPeo ple_SelectedInd exChanged" GridLines="Hori zontal" Width="100%">

<Columns>

<asp:TemplateFi eld>



<ItemTemplate >

<asp:ImageButto n ID="btnDSelect " runat="server" ImageUrl="../images/ok.png"

ToolTip="Displa y Deal Details" CommandArgument ='<%# Bind("CoDetailI D") %>' OnClick="btnCSe lect_Click"/>

</ItemTemplate>

<ItemStyle VerticalAlign=" Top" />

</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Com pany Type">

<ItemTemplate >

<table>

<tr>

<td></td>

<td><asp:DropDo wnList ID="ddlCoType" runat="server" CssClass="form" >

</asp:DropDownLis t>

<asp:Label ID="DetailID" runat="server" Text='<%# Bind("CoDetailI D") %>' Visible="False" ></asp:Label></td>

<td valign="top"><a sp:Label ID="Label2" runat="server" Text="Hired By:" Height="1px" Width="50px"></asp:Label></td>

<td valign="top"><a sp:DropDownList ID="ddlClientLi st" runat="server" AppendDataBound Items="true" CssClass="form" >

<asp:ListItem Text ="Please Select" Value="0" />

</asp:DropDownLis t></td>

</tr>

</table>



</ItemTemplate>

<ItemStyle Width="10px" VerticalAlign=" Top" />

<HeaderStyle HorizontalAlign ="Center" />

</asp:TemplateFie ld>

<asp:TemplateFi eld HeaderText="Com pany Role">

<ItemTemplate >

<asp:TextBox ID="tbCoRole" runat="server" CssClass ="form"></asp:TextBox>

</ItemTemplate>

<ItemStyle Width="10px" VerticalAlign=" Top" />

<HeaderStyle HorizontalAlign ="Center" />

</asp:TemplateFie ld>

<asp:BoundFie ld DataField="Comp any" HeaderText="Com pany" >

<ItemStyle Width="80px" VerticalAlign=" Top" />

<HeaderStyle HorizontalAlign ="Center" />

</asp:BoundField>

<asp:BoundFie ld DataField="City " HeaderText="Cit y" >

<ItemStyle Width="40px" VerticalAlign=" Top" />

<HeaderStyle HorizontalAlign ="Center" />

</asp:BoundField>

<asp:BoundFie ld DataField="Stat e" HeaderText="Sta te" >

<ItemStyle Width="20px" VerticalAlign=" Top" />

<HeaderStyle HorizontalAlign ="Center" />

</asp:BoundField>

<asp:BoundFie ld DataField="Coun try" HeaderText="Cou ntry" >

<ItemStyle Width="50px" VerticalAlign=" Top" />

<HeaderStyle HorizontalAlign ="Center" />

</asp:BoundField>

<asp:ButtonFiel d ButtonType ="Image" CommandName="Sh ow" ImageUrl="../images/add.png" >

<ItemStyle VerticalAlign=" Top" />

</asp:ButtonField >

<asp:ButtonFiel d ButtonType ="Image" CommandName="Hi de" ImageUrl="../images/remove.png" >

<ItemStyle VerticalAlign=" Top" />

</asp:ButtonField >

<asp:TemplateFi eld HeaderText="Peo ple List">

<ItemTemplate > /// Nested people gridview

<asp:GridView ID="grdPersons " runat="server" AutoGenerateCol umns ="false" DataKeyNames ="PersonID" GridLines="Hori zontal" HeaderStyle-CssClass="head_ 1" Width="160px">

<Columns>

<asp:TemplateFi eld>

<HeaderStyle HorizontalAlign ="left" />

<HeaderTemplate >

<asp:CheckBox ID="chkSelectAl l" ToolTip="Click here to select/deselect all rows"

runat="server" />

</HeaderTemplate>

<ItemTemplate >

<asp:CheckBox ID="chkSelect" runat="server" />

<asp:ImageButto n ID="btnPersonSe lect" runat="server" ImageUrl="../images/ok.png"

ToolTip="Displa y People Details" CommandArgument ='<%# Bind("PersonID" ) %>' OnClick="btnPer sonSelect_Click "/>

</ItemTemplate>

<ItemStyle Width="5px" />

</asp:TemplateFie ld>

<asp:BoundFie ld DataField="Full Name" HeaderText="Nam e" >

<ItemStyle Width="150px" />

</asp:BoundField>

<asp:BoundFie ld DataField="Titl e" HeaderText="Job Title" />

</Columns>

</asp:GridView>

</ItemTemplate>

<HeaderStyle HorizontalAlign ="Center" />

<ItemStyle VerticalAlign=" Top" Width="250px" />

</asp:TemplateFie ld>

</Columns>

<FooterStyle CssClass="head_ 1" />

<HeaderStyle CssClass="head_ 1" />

</asp:GridView>
//Binding the nested people grid in parent company gridview rowdatabound event
protected void grdCompanyPeopl e_RowDataBound( Object sender, GridViewRowEven tArgs e)
{

if (e.Row.RowType == DataControlRowT ype.DataRow)
{

GridView People = e.Row.FindContr ol("grdPersons" ) as GridView;
String DetailID = (e.Row.FindCont rol("DetailID") as Label).Text.ToS tring();

int RecordCount;
DataSet DS = new DataSet();

String Cmd = "stored procedure name" + DetailID;
DS = info.SelectDSQu ery(Cmd);

RecordCount = DS.Tables.Count ;

People.Visible = false;if (RecordCount > 0)
{

People.DataSour ce = DS.Tables[0];

People.DataBind ();

}

CheckBox chk = (CheckBox)Peopl e.FindControl(" chkSelect");if (chk != null)
{

chk.Attributes. Add("onclick", "SelectRow( )");
}

foreach (GridViewRow rw in People.Rows)
{

rw.Attributes.A dd("onclick", "SelectRow( )");

rw.Attributes.A dd("title", "Click to toggle the selection of this row");
}

}

}

//Trying to get the personid of the checked rows but not able to find the nested gridview in this method

protected void Showselection()
{

GridView People = grdCompanyPeopl e.FindControl(" grdPersons") as GridView; // this is returning null valueforeach (GridViewRow rw in People.Rows)
{

CheckBox chk = (CheckBox)rw.Fi ndControl("chkS elect");

if (chk != null)
{

if (chk.Checked)
{

string PersonID = People.DataKeys[rw.RowIndex]["PersonID"].ToString()+"," ;
Response.Write( PersonID.ToStri ng());

}

}

}

}
Aug 13 '07 #1
0 4650

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

Similar topics

0
2197
by: hammad.awan_nospam | last post by:
Hello, I am using ASP.NET 2.0. What I have done is nested a gridview inside another column of a gridview using a template data field column declaritively in my web form. Inside this child gridview I have set an ItemStyle property of width 20% for the first templated field which contains a hyperlink control, and an ItemStyle of width 80%...
3
19332
by: Martin | last post by:
Hi, I have a very frustrating problem that I have researched for countless hours to no avail. There are many posts asking very similar things, however none usefull in my situation. I am using VS 2005 (ASP 2.0) and VB .NET. I have a page with a datalist, a gridview and then other data controls, nested in that order. This all works great,...
0
2791
by: manuel.ricca | last post by:
Hello, I'm trying to create a table with 2 nested gridviews and then a DetailsView on the right. The DetailsView should show the details of the item selected in the 2nd (nested) GridView: My "master" table is like this: A1
1
1949
by: Roy | last post by:
Hey all. Below is the nested syntax on how to make a "codeless" nested gridview embedded within another gridviews templatefield column. Only problem is that it loads slow. REAL SLOW. There has to be a better way. Suggestions anyone? By the way, I'm not opposed to coding, it just seems like this should be easily doable on the aspx side of...
1
3077
by: sheenaa | last post by:
Hello friends, I m using ASP.NET with C# 2005 and SQL SERVER 2005 for the ASP.Net Website. I m using sqldatasource to connect and retrieve the data from database and then it displays the data in the gridview on the button click event.I have created the stored procedure for insert and select query. Now in my application i have used...
3
2640
by: RobertTheProgrammer | last post by:
Hi folks, I've got another problem. Basically, I'm trying to use a nested GridView, however the nexted GridView displays no values (even though in debug I'm getting valid values into my DataSet. It's probably a binding issue somewhere, but I'm not sure where. Here's the ASP (slightly edited to remove verbosity): <asp:GridView...
6
5744
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 OnSelectedIndexChanged event set on it. This triggers just fine, but within the codebehind of the OnSelectedIndexChanged event, I need to scan through all the entries...
2
5327
by: Michael | last post by:
It seems that a gridview allows us to delete only a single row at a time. How to extend this functionality to select multiple rows and delete all of the selected rows in a single stroke? just like what hotmail web UI is doing now (having the option of selecting multiple rows (using the checkbox provided) and perform a set of operations on them)
2
2597
by: ASF | last post by:
Hey all, I have a gridview which pulls from a BLL which pulls from a DAL (an .XSD file). Each row on that gridview has a nested repeater which pulls from another table. The code which populates each nested repeater is shown below (it's in the gridview's RowDataBound event). My question is this: what can I do to speed up this process?...
0
7888
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7811
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8159
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8314
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7922
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5689
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5366
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3811
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2317
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.