Click here to Skip to main content
15,848,157 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am successfully displaying a modal popup invoked from a button onClick event similar to the one below. Is there a way to also call the BtnViewDetails method (below) from a selected radiobuttonlist value?

protected void BtnViewDetails_Click(object sender, EventArgs e)
       //  get the gridviewrow from the sender so we can get the datakey we need
       Button btnDetails = sender as Button;
       GridViewRow row = (GridViewRow)btnDetails.NamingContainer;

       //  extract the customerid from the row whose details button originated the postback.
       //  grab the customerid and feed it to the customer details datasource
       //  finally, rebind the detailview
       this.sqldsCustomerDetails.SelectParameters.Add("customerid", Convert.ToString(this.gvCustomers.DataKeys[row.RowIndex].Value));
       this.dvCustomerDetail.DataSource = this.sqldsCustomerDetails;
       //  update the contents in the detail panel
       //  show the modal popup
Updated 8-Feb-11 13:48pm
DaveAuld 8-Feb-11 18:48pm    
Edit: Added code block formatting
Ankur\m/ 21-Feb-11 8:31am    
I moved your answer to a comment for obvious reasons. :)

1 solution

Of course you can!

You have a handler working now that calls a modal popup; the cheap and dirty way is to add a call to BtnViewDetails_Click() to that handler. The elegant way is to add a custom handler to intercept the custom event BtnViewDetails_Click event. I'd personally opt for the easy way, but I'm not a professional programmer.
Share this answer
CSharpNewcomer 9-Feb-11 18:36pm    
Yes you are correct, but in this specific case you are calling the method upon selecting a particular radiobuttonlist value. I think this might be a special case where a DB valued modal popup is called after selection of a radiobuttonlist value.
Ankur\m/ 21-Feb-11 8:31am    
[moved from answer]
OP wrote:
I have resolved this question.

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