Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi,
I have 3 row(Contractor,team lead,manager) in first column in datagrid and second column button is there. whenever i m clicking on button for contractor it is opening another window. after that this contractor name should display in another grid in one column label.

same way when i will clicking on button for team lead , it is opening another window and after that this team lead name should display in another grid in one column label.

internal DataTable goodsAddTable(DataTable _dtblanck, string LoginName)
        {
            int constant = 0;
            DataRow _drNewRow = _dtblanck.NewRow();

            for (int _cnt = 1; _cnt < 4; _cnt++)
            {
                _drNewRow = _dtblanck.NewRow();
                
                if(_cnt==1)
                  _drNewRow["mio_source"] = "Contractor";
                else if (_cnt == 2)
                    _drNewRow["mio_source"] = "team lead";
                else if (_cnt == 3)
                    _drNewRow["mio_source"] = "manager";
                _drNewRow["mio_id"] = --constant;
                

                _dtblanck.Rows.Add(_drNewRow);
            }
            return _dtblanck;
Posted
Comments
Karthik_Mahalingam 16-Jan-14 7:09am    
asp.net or windows ??

new page or pop up window ???

Please provide more info....
kamalsekhar 16-Jan-14 23:34pm    
Hi Karthik,
I am using popup window using javascript and my application is web based .i m using datagrid and in that grid GetProducts button.when we click on any button with respective team lead or manager,in that popup window, that team lead or manager based on button click event, name should display in one column.how to do using popup window
ASPX page code--
<asp:DataGrid ID="dgproduct">

<asp:TemplateColumn HeaderStyle-VerticalAlign="Middle" HeaderStyle-Width="150px">
<HeaderTemplate>List of Goods</HeaderTemplate>


<asp:Button ID="btnListOfProducts" runat="server" Text="List of Products" class="Button" Width="100px" onclientclick="ListofProducts()" />






Javascript code----

<script type="text/javascript" >

function ListofProducts() {

window.open("ProductsList.aspx", "", "toolbar=0,resizable=1,scrollbars=1,statusbar=0,menubar=0,height=1000,width=1300,resizable=1,top=0,left=0");


}
</script>
Simon_Whale 16-Jan-14 7:14am    
what code are you using to open the new window?
kamalsekhar 16-Jan-14 23:33pm    
Javascript code----

<script type="text/javascript" >

function ListofProducts() {

window.open("ProductsList.aspx", "", "toolbar=0,resizable=1,scrollbars=1,statusbar=0,menubar=0,height=1000,width=1300,resizable=1,top=0,left=0");


}
</script>

for opening new window javascript i m using. now my problem is how to pass id or value to another page based on button click event
Karthik_Mahalingam 17-Jan-14 0:54am    
you want to open in new window ??

1 solution

Try like this
here iam using Query String to pass values from one page to another you can use Session,Cookies also...

Page 1

ASP.NET
<asp:GridView ID="GridView1" AutoGenerateColumns="false" runat="server">
           <Columns>
               <asp:BoundField HeaderText="mio_source" DataField="mio_source" />
               <asp:TemplateField>
                   <ItemTemplate>
                       <asp:Button ID="btn" runat="server" Text="GOTO" OnClick="btn_Click" />
                   </ItemTemplate>
               </asp:TemplateField>
           </Columns>
       </asp:GridView>


C#
protected void Page_Load(object sender, EventArgs e)
        {
            if( !Page.IsPostBack)
            {
                DataTable dt = new DataTable ();
                dt.Columns.Add("mio_source",typeof(string));
                dt.Rows.Add("Contractor");
                dt.Rows.Add("team lead");
                dt.Rows.Add("manager");

                GridView1.DataSource = dt;
                GridView1.DataBind();

            }
        }

        protected void btn_Click(object sender, EventArgs e)
        {
            var row = (sender as Button).Parent.Parent as GridViewRow;
               string  mio_source  = row.Cells[0].Text;
               Response.Redirect("Page2.aspx?mio_source=" + mio_source);
        }



Page 2
ASP.NET
<asp:label id="labelmio_source" runat="server" text="Label" xmlns:asp="#unknown"></asp:label>


code behind:

C#
protected void Page_Load(object sender, EventArgs e)
       {
           if (!Page.IsPostBack)
           {
              labelmio_source.Text = Request.QueryString["mio_source"] + "";

           }
       }


For more info on query string : Passing variables between pages using QueryString[^]
 
Share this answer
 
v2
Comments
kamalsekhar 16-Jan-14 9:04am    
var row = (sender as Button).Parent.Parent as GridViewRow; --is this line will wok for datagrid ??
Karthik_Mahalingam 16-Jan-14 10:03am    
no idea,
did u tried ??
kamalsekhar 17-Jan-14 0:59am    
Hi Karthik,
can u give all source code for datagrid ???pls
Karthik_Mahalingam 17-Jan-14 1:04am    
u need to open in new popup ??
Karthik_Mahalingam 17-Jan-14 1:06am    
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
var OpenWindow = function (mio_source) {
var url = 'Page2.aspx?mio_source=' + mio_source.title;
window.open(url);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" AutoGenerateColumns="false" runat="server">
<columns>
<asp:BoundField HeaderText="mio_source" DataField="mio_source" />
<asp:TemplateField>
<itemtemplate>
<asp:Button ID="btn" runat="server" ToolTip='<%# Bind("mio_source") %>' Text="GOTO" OnClientClick="OpenWindow(this); return false;" />




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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900