shilpi gupta

shilpi gupta

  • NA
  • 49
  • 72.4k

showing data in 2nd gridview on select arow from 1st grid

Jun 10 2010 6:59 AM
 I want "showing  data in 2nd gridview on select arow from 1st grid"
but it show only one 1st grid data & selection not work

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
    </div>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
        DataKeyNames="EmployeeID" DataSourceID="SqlDataSource1" AllowPaging="True"
        AllowSorting="True">
        <Columns>
            <asp:CommandField ShowSelectButton="True"  />
            <asp:BoundField DataField="EmployeeID" HeaderText="EmployeeID"
                InsertVisible="False" ReadOnly="True" SortExpression="EmployeeID" />
            <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
            <asp:BoundField DataField="BirthDate" HeaderText="BirthDate"
                SortExpression="BirthDate" />
            <asp:BoundField DataField="MaritalStatus" HeaderText="MaritalStatus"
                SortExpression="MaritalStatus" />
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="<%$ ConnectionStrings:AdventureWorksConnectionString %>"
        SelectCommand="SELECT EmployeeID, Title, BirthDate, MaritalStatus FROM HumanResources.Employee">
    </asp:SqlDataSource>
    <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"
        DataSourceID="SqlDataSource2">
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server"
        ConnectionString="<%$ ConnectionStrings:AdventureWorksConnectionString2 %>"
       
        SelectCommand="SELECT HumanResources.Employee.EmployeeID, HumanResources.EmployeeDepartmentHistory.StartDate, HumanResources.EmployeeDepartmentHistory.EndDate, HumanResources.EmployeePayHistory.Rate, HumanResources.EmployeePayHistory.RateChangeDate, HumanResources.EmployeePayHistory.PayFrequency FROM HumanResources.Employee INNER JOIN HumanResources.EmployeeDepartmentHistory ON HumanResources.Employee.EmployeeID = HumanResources.EmployeeDepartmentHistory.EmployeeID INNER JOIN HumanResources.EmployeePayHistory ON HumanResources.Employee.EmployeeID = HumanResources.EmployeePayHistory.EmployeeID WHERE (HumanResources.Employee.EmployeeID = @EmployeeID)" >
        <SelectParameters>
            <asp:ControlParameter ControlID="GridView1"
                DefaultValue="SelectedDataKey.Values[&amp;quot;EmployeeID&amp;quot;]" Name="EmployeeID"
                PropertyName="SelectedDataKey" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
    </form>
</body>
</html>


Answers (1)