Click here to Skip to main content
14,301,387 members
Rate this:
Please Sign up or sign in to 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....
Simon_Whale 16-Jan-14 7:14am
   
what code are you using to open the new window?
kamalsekhar 16-Jan-14 9:01am
   
Hi,
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> <itemtemplate>

<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>
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
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>
Karthik_Mahalingam 17-Jan-14 0:54am
   
you want to open in new window ??

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

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: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>


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:label id="labelmio_source" runat="server" text="Label" xmlns:asp="#unknown"></asp:label>


code behind:

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[^]
   
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>
kamalsekhar 17-Jan-14 2:15am
   
Hi Kathik,
Can u pls send me C# code also ??becz from where mio_source will take/how will bind
kamalsekhar 17-Jan-14 3:05am
   
Thanks karthik. i solved this issue. but i m having another issue.

Hi,
I want to open in new window like popup. in this below code, its opening in new tab. i dont want to open in new tab. it should open new popup window. how to do.
<pre lang="xml">if (e.CommandName == "Update")
{


Response.Write("<script type='text/javascript'>window.open('ProductsList.aspx?ID=" + e.Item.Cells[2].Text + "','_blank');</script>");



}</pre>
Karthik_Mahalingam 17-Jan-14 3:31am
   
try like this..

window.open("http://www.google.com",'google','height=200,width=150');
it will open in pop up window , not tab
kamalsekhar 17-Jan-14 3:42am
   
Hi Kaarthik,
please se my code properly in above.
I am passing ID with page

ProductsList.aspx?ID=" + e.Item.Cells[2].Text +
Karthik_Mahalingam 17-Jan-14 3:47am
   
i have given u just an example,
means you have define the height and width of the window. then only it will display as popup else it will open in new tab.
Got IT ????

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100