Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 26, 2012 06:45 AM by shameelfaraz
None
0 Points
5 Posts
Dec 25, 2012 02:30 PM|LINK
i use a following code in rowdatabound event
if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes["onClick"] = string.Format("window.location = 'CandidateProfile.aspx?candidateID={0}';", DataBinder.Eval(e.Row.DataItem, "candidateID"))
}
i want to change it so the click event opens in a new window with specified height and width
how can i do that , plz help
Star
13599 Points
2691 Posts
Dec 25, 2012 02:36 PM|LINK
Hi,
Try like the following
http://forums.asp.net/t/1091955.aspx/1
All-Star
118619 Points
18779 Posts
Dec 26, 2012 01:36 AM|LINK
shameelfaraz Attributes["onClick"]
Change your "Click" to "click", because js is case-sensitive:
[aspx]
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="CSharp.WebForm1" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:GridView ID="GridView1" runat="server" OnRowDataBound="GridView1_RowDataBound"></asp:GridView> </div> </form> </body> </html>
[cs]
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes["onclick"] = "javaxcript:window.open('http://www.google.com')"; } }
Dec 26, 2012 06:38 AM|LINK
i tried this
e.Row.Attributes.Add("oncl
Dec 26, 2012 06:40 AM|LINK
shameelfaraz i dont want the click event in the last column of the grid as it has button in that column
What does this mean?
Dec 26, 2012 06:42 AM|LINK
i mean that right now wen i click anywhere in a row the click event fires , but i dont want it to fire at the last column , the last column has button in it which fires on row command
Dec 26, 2012 06:45 AM|LINK
nevermind i got it
if (e.Row.RowType == DataControlRowType.DataRow && e.Row.RowState == DataControlRowState.Alternate) { if (e.Row.RowType == DataControlRowType.DataRow) { for (x=0; x < cellCount-1; x++ ) e.Row.Cells[x].Attributes.Add("onclick", "javascript:window.open('CandidateProfile.aspx?candidateID=" + DataBinder.Eval(e.Row.DataItem, "candidateID") + "',null,'left=162px, top=134px, width=500px, height=500px, status=no, resizable= yes, scrollbars=yes, toolbar=no, location=no, menubar=no');"); } }
shameelfaraz
None
0 Points
5 Posts
How can I use the RowDataBound declaration on a GridView to navigate away to new .aspx page with ...
Dec 25, 2012 02:30 PM|LINK
i use a following code in rowdatabound event
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onClick"] = string.Format("window.location = 'CandidateProfile.aspx?candidateID={0}';", DataBinder.Eval(e.Row.DataItem, "candidateID"))
}
i want to change it so the click event opens in a new window with specified height and width
how can i do that , plz help
sarathi125
Star
13599 Points
2691 Posts
Re: How can I use the RowDataBound declaration on a GridView to navigate away to new .aspx page w...
Dec 25, 2012 02:36 PM|LINK
Hi,
Try like the following
http://forums.asp.net/t/1091955.aspx/1
Remember to click Mark as Answer on the post that helps to others.
My Blog :MyAspSnippets
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: How can I use the RowDataBound declaration on a GridView to navigate away to new .aspx page w...
Dec 26, 2012 01:36 AM|LINK
Hi,
Change your "Click" to "click", because js is case-sensitive:
[aspx]
[cs]
shameelfaraz
None
0 Points
5 Posts
Re: How can I use the RowDataBound declaration on a GridView to navigate away to new .aspx page w...
Dec 26, 2012 06:38 AM|LINK
i tried this
<div class="first last">e.Row.Attributes.Add("oncl
it works but i dont want the click event in the last column of the grid as it has button in that column </div>
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: How can I use the RowDataBound declaration on a GridView to navigate away to new .aspx page w...
Dec 26, 2012 06:40 AM|LINK
What does this mean?
shameelfaraz
None
0 Points
5 Posts
Re: How can I use the RowDataBound declaration on a GridView to navigate away to new .aspx page w...
Dec 26, 2012 06:42 AM|LINK
i mean that right now wen i click anywhere in a row the click event fires , but i dont want it to fire at the last column , the last column has button in it which fires on row command
shameelfaraz
None
0 Points
5 Posts
Re: How can I use the RowDataBound declaration on a GridView to navigate away to new .aspx page w...
Dec 26, 2012 06:45 AM|LINK
nevermind i got it
if (e.Row.RowType == DataControlRowType.DataRow && e.Row.RowState == DataControlRowState.Alternate)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
for (x=0; x < cellCount-1; x++ )
e.Row.Cells[x].Attributes.Add("onclick", "javascript:window.open('CandidateProfile.aspx?candidateID=" + DataBinder.Eval(e.Row.DataItem, "candidateID") + "',null,'left=162px, top=134px, width=500px, height=500px, status=no, resizable= yes, scrollbars=yes, toolbar=no, location=no, menubar=no');");
}
}