Code:protected void l_no_Click(object sender, EventArgs e) { // Fetch the customer id LinkButton lb = sender as LinkButton; string custID = lb.Text; lblCustValue.Text = custID; // 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(); }Code:<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" AllowPaging="True" DataSourceID="SqlDataSource1" onselectedindexchanged="GridView1_SelectedIndexChanged" > <Columns> <asp:TemplateField HeaderText="l_no"> <ItemTemplate> <asp:LinkButton runat="server" ID ="l_no" Text='<%# Eval("l_no") %>' OnClick="l_no_Click" /> </ItemTemplate> </asp:TemplateField> <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:BoundField DataField="le_yn" HeaderText="le_yn" SortExpression="le_yn" /> <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"> Hold here to Drag this Box </asp:Panel> <asp:Label runat="server" ID="lblText" Text="CustomerID: "></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> </asp:Content>


Reply With Quote


Bookmarks