1

Work on Asp.Net C# VS08.

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

<!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">


<link href="StyleSheet.css" rel="stylesheet" type="text/css" />

    <title>Untitled Page</title>
        <link href="StyleSheet.css" rel="stylesheet" type="text/css" />    
    <script type="text/javascript">
    var styleToSelect;
    function onOk() {
    document.getElementById('GridView1').className = styleToSelect;
    }
</script>


<script language="javascript" type="text/javascript">

    function GetRowValue(val) {

   // alert(val);

        document.getElementById("Text1").value = val;

        // hardcoded value used to minimize the code.

        // ControlID can instead be passed as query string to the popup window

        //window.opener.document.getElementById("ctl00_ContentPlaceHolder2_GridView1_txtCOM_NAME").value = val;
        //window.opener.document.getElementById('%=txtCOM_NAME.ClientId%>').value = val;
        //window.opener.document.getElementById("txtParent").value = val;
        //Text1.innerHTML=val;
       // alert(val);


       // window.close();

    }

    function Hello()
    {
     document.getElementById("Text1").value="2";
    }
    </script>





</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>

    <asp:LinkButton ID="LinkButton1" runat="server">Please click to select an alternate text style.</asp:LinkButton><br />
        <br />
        <asp:Button ID="Button1" runat="server" Text="Button" /><br />
        <br />
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="CategoryID"
            DataSourceID="SqlDataSource1">
            <Columns>
                <asp:BoundField DataField="CategoryID" HeaderText="CategoryID" InsertVisible="False"
                    ReadOnly="True" SortExpression="CategoryID" />
                <asp:BoundField DataField="CategoryName" HeaderText="CategoryName" SortExpression="CategoryName" />
                <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                <asp:TemplateField>
                    <ItemTemplate>



                        <asp:Button ID="Button2" runat="server" Text="Button" />                       


                        <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" 
             TargetControlID="Button2"
             PopupControlID="Panel2"  



             BackgroundCssClass="modalBackground"
             DropShadow="true"

             OkControlID="OkButton"

             CancelControlID="CancelButton"

             OnOkScript="onOk()"




             />
                        &nbsp;<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>


                    </ItemTemplate>


                </asp:TemplateField>

            </Columns>
        </asp:GridView>


        <asp:Panel ID="Panel2" runat="server" Height="50px" Width="125px" CssClass="modalPopup">
                            &nbsp;<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataKeyNames="CategoryID"
                                DataSourceID="SqlDataSource1" OnSelectedIndexChanged="GridView2_SelectedIndexChanged" OnRowDataBound="GridView2_RowDataBound">
                                <Columns>
                                    <asp:TemplateField HeaderText="ckb">
                                        <EditItemTemplate>
                                            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                                        </EditItemTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="Label1" runat="server"></asp:Label>
                                            <asp:CheckBox ID="CheckBox1" runat="server" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:CommandField ShowSelectButton="True" />
                                    <asp:BoundField DataField="CategoryID" HeaderText="CategoryID" InsertVisible="False"
                                        ReadOnly="True" SortExpression="CategoryID" />
                                    <asp:BoundField DataField="CategoryName" HeaderText="CategoryName" SortExpression="CategoryName" />
                                    <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />

                                     <asp:TemplateField>
                                        <AlternatingItemTemplate>
                                            <asp:Button ID="btnSelect" runat="server" Text="Select" />
                                        </AlternatingItemTemplate>
                                        <ItemTemplate>
                                            <asp:Button ID="btnSelect" runat="server" Text="Select" />
                                        </ItemTemplate>
                                    </asp:TemplateField>

                                </Columns>
                            </asp:GridView>
                        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            <asp:HiddenField ID="HiddenField1" runat="server" />
            <asp:Button ID="Button3" runat="server" Text="Button" />

                                <div align="center">
      <asp:Button ID="OkButton" runat="server" Text="OK" OnClick="OkButton_Click"  OnClientClick=Hello() />
      <asp:Button ID="CancelButton" runat="server" Text="Cancel" />
                                    <input id="Button4" type="button" value="button" /></div>


            </asp:Panel>

        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
            SelectCommand="SELECT [CategoryID], [CategoryName], [Description] FROM [Categories]">
        </asp:SqlDataSource>
        <br />
        <br />
        <br />
        <br />
        &nbsp;



    </div>

    </form>
</body>
</html>

After Popup .Want to select a row on popup grid then click on ok button and put the value on TextBox fo the parent grid.How to set value on Parent Grid.

1 Answer 1

1

I guess you should use the row command event handler of the grid, if I got you right:

OnRowCommand="RowCommand"

Then you can add a button to the grid:

<asp:LinkButton ID="LnkButton" runat="server" CommandName="setValue" CommandArgument='<%# Eval("id")%>'>Set value</asp:LinkButton>

And a method to handle it:

protected void RowCommand(Object sender, GridViewCommandEventArgs e)
  if (e.CommandName=="setValue")
    [do something with e.CommandArgument and close dialog]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.