0

I want retrive anthor table from linkbutton inside gridview,But cannot get result i want Please help me .
Main gridview table is viewyn

CREATE TABLE [dbo].[viewyn]
[l_no] [varchar](50) ,
[nam_dep] [varchar](50) ,
[no_deo] [int] NULL,
[no_mon] [int] NULL,
[le_yn] [varchar](50) ,
[dd_yn] [varchar](50)


le_yn is used linkbuttons
Now anthor table
CREATE TABLE [dbo].[Letter_dept](
[Dep_nam] [varchar](50),
[l_no] [varchar](50),
[le_jap] [varchar](50),
[date] [varchar](50),
[amount_dd] [int] NULL,
[le_yn] [varchar](50)

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>

<asp:GridView ID="GridView1" runat="server" 
AutoGenerateColumns="False" AllowPaging="True" DataSourceID="SqlDataSource1" 
        onselectedindexchanged="GridView1_SelectedIndexChanged" >
           <Columns>
            <asp:BoundField DataField="l_no" HeaderText="l_no" 
                   SortExpression="l_no" />
                   
                   
            
                            
               <asp:BoundField DataField="nam_dep" HeaderText="nam_dep" 
                   SortExpression="nam_dep" />
               <asp:BoundField DataField="no_deo" HeaderText="no_deo" 
                   SortExpression="no_deo" />
               <asp:BoundField DataField="no_mon" HeaderText="no_mon" 
                   SortExpression="no_mon" />
                   <asp:TemplateField HeaderText="le_yn">
                   <ItemTemplate>
                   <asp:Label runat="server" ID="letterno" Text='<%# Eval("le_yn") %>'  />
                   <asp:LinkButton  runat="server" ID ="l_no"  Text='<%# Eval("l_no") %>'  OnClick="l_no_Click"   />
                   </ItemTemplate>
                   </asp:TemplateField>             
                   
                   
                       
                  
                   
                   
              
               <asp:BoundField DataField="dd_yn" HeaderText="dd_yn" SortExpression="dd_yn" />
           </Columns>
           </asp:GridView>
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
    TargetControlID="btnShowModalPopup"
    PopupControlID="divPopUp"
    BackgroundCssClass="popUpStyle"
    PopupDragHandleControlID="panelDragHandle"
    DropShadow="true">   </asp:ModalPopupExtender>
<asp:Button runat="server" ID="btnShowModalPopup" style="display:none"/>


        <div class="popUpStyle"  id="divPopUp"  style="display:none;">
    <asp:Panel runat="Server" ID="panelDragHandle" CssClass="drag">
        
    </asp:Panel>
    <asp:Label runat="server" ID="lblText" Text="letter no: "></asp:Label>
    <asp:Label ID="lblCustValue" runat="server"></asp:Label>
    <asp:GridView ID="GridView2" runat="server">
    </asp:GridView>                         
    <asp:Button ID="btnClose" runat="server" Text="Close" />
   <br />
</div>       
    </ContentTemplate>
</asp:UpdatePanel>
  
   <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:JAPITConnectionString %>" 
        SelectCommand="SELECT * FROM [viewyn]"></asp:SqlDataSource>
protected void l_no_Click(object sender, EventArgs e)
    {
        // Fetch the customer id
        LinkButton lb = sender as LinkButton;
        string l_no = lb.Text;
        lblCustValue.Text = l_no;
        // Connection
        string constr = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["JAPITConnectionString"].ConnectionString;
        string sql = "SELECT * FROM Letter_dept WHERE l_no= @l_no";
        SqlConnection connection = new SqlConnection(constr);
        connection.Open();
        SqlCommand cmd = new SqlCommand(sql, connection);
        cmd.Parameters.AddWithValue("@l_no", l_no);
        cmd.CommandType = CommandType.Text;
        
        SqlDataReader dr = cmd.ExecuteReader();
        // Bind the reader to the GridView
        // You can also use a lighter control
        // like the Repeater to display data
        GridView2.DataSource = dr;
        GridView2.DataBind();
        connection.Close();
        // Show the modalpopupextender
        ModalPopupExtender1.Show();

    }
2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by |-|x
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.