Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Need help w/popup from GridView in ASP.Net 2.0

Posted on 2007-04-07
3
Medium Priority
?
1,220 Views
Last Modified: 2013-11-07
I'm experienced in vb.net, but new to asp.net.  I'm trying to put together a webpage to run SQL '05 reports.  The page needs to be hosted in another existing web-app using the same style, or else I would just use the standard SQL '05 reports web-interface.  I'm trying to use a GridView listing report name, description, and a "Run" button to launch another page that hosts the ReportViewer control to display the report.  I have an asp:Button in a template column in the GridView.  I'm using the following to register a javascript function in the page load event:

        Dim sb As New System.Text.StringBuilder
        sb.Append("<script language='javascript'>")
        sb.Append("window.open('ReportRun.aspx', 'RepDialog',")
        sb.Append("'width=800, height=600, menubar=no, resizable=yes');<")
        sb.Append("/script>")
        Page.ClientScript.RegisterClientScriptBlock(Me.GetType, "repScript", sb.ToString)

In the RowDataBound even I have the following:

        If (e.Row.RowType = DataControlRowType.DataRow) Then
            Dim oBtn As Button = DirectCast(e.Row.Cells(0).FindControl("RepBtn"), Button)
            oBtn.Attributes.Add("onClientClick", "repScript")
        End If

The problem is that the popup is being shown when I click any button in that row of the GridView.  I'm also trying to figure out how to pass an item from the clicked row (the report name in this case) to the popup window page (which hosts a ReportViewer control, so I need to tell it which report to run).  I'm guessing I could just use a session item for this, but I need to know how to get the row that was clicked.  Any input?
0
Comment
Question by:feezymac
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 14

Accepted Solution

by:
steveberzins earned 2000 total points
ID: 18870999
it looks like the popup is running any time the page is loaded.

I'd create the client script as a function
<script>
function RunReport(reportName) {
 window.open('reportrun.aspx?name=" + reportName.... blah blah);
}
</script>

then, in your code that creates the 'clicker event', change it to look something like
oBtn.Attributes.Add("onclientclick", "RunReport('" + HttpUtility.HtmlEncode(Eval("REPORT_NAME")) + "');")

this isn't debugged at all, just enough to show you where I'm goin'

Steve
0
 
LVL 13

Expert Comment

by:jeebukarthikeyan
ID: 18875396
hi,

this is the html code

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=XYKAPC_21;Initial Catalog=Northwind;Persist Security Info=True;User ID=sa;Password=sa"
            ProviderName="System.Data.SqlClient" SelectCommand="SELECT *  FROM Employees"></asp:SqlDataSource>
   
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataMember="DefaultView"   DataSourceID="SqlDataSource1" OnRowDataBound="GridView1_RowDataBound">
            <Columns>
                <asp:BoundField DataField="EmployeeID" HeaderText="EmployeeID" />
                <asp:BoundField DataField="FirstName" HeaderText="FirstName" />
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:Button ID="Button1" runat="server" Text="Button" />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>

create a script like this in the head part of the aspx
<script language='javascript'>
  function Open(var1)
  {
  alert(var1);
        window.open('ReportRun.aspx', 'RepDialog','width=800, height=600, menubar=no, resizable=yes');
  }
        </script>

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Button btn = new Button();
            btn = (Button)e.Row.Cells[2].FindControl("Button1");

            btn.Attributes.Add("OnClick", "javascript:Open('" + e.Row.Cells[1].Text + "')");

        }

    }

b u d d h a

0
 

Author Comment

by:feezymac
ID: 18895128
I feel so dumb now, that seems so obvious :)  I'm not a big fan of web apps, so this project is a struggle for me, but that short snippet cleared up a few misconceptions I've had so far and really put me on the right track.  I was able to finish up the basic layout so I moved to a more involved UI, next I'll AJAX the edit pages :)  Thanks again.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

While opting for any web-to-print solution, you need to discuss with your team and some of your end users and know their opinions about your decisions. In this article we list down some questions you need to ask yourself.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question