I have a grid view (where i view information on potential customers) where once I click on a button beside a specific record, it brings me to a popup form for me to add additional information for the specific potential customer. The only thing is once I
click on that button, I want to pass the PotentialCustomerNo and have it displayed in a text box of the same name in the pop up form where I am entering the additional information. How can I do this?
Ok i tried it so far. when i run it however, I get the following exception:
Object reference not set to an instance of an object.
Description:
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 32: {
Line 33: Button btndetails = sender as Button;
Line 34: GridViewRow gvrow = new GridViewRow(); Line 35: gvrow = (GridViewRow)btndetails.NamingContainer;
Since you're not posting any html / code i'll assume you didn't build your page corectly.
The NamingContainer should contain its parent container which should be your GrdiViewRow. This assumes you have a GridView and not something else. Then your button should be part of that GridViewRow.
Run your debugger and see what's in btndetails.NamingContainer before trying to cast that as a GridViewRow.
Ok I realised that for the btndetails variable, I declared it as the wrong type. It should have been a LinkButton. After I do that however, I get another exception. Please see below:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Description:
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Source Error:
Line 33: LinkButton btndetails = sender as LinkButton;
Line 34: GridViewRow gvrow = (GridViewRow)btndetails.NamingContainer;
Line 35: potentialCustNoLabelID.Text = Potentialcustgrid2.DataKeys[gvrow.RowIndex].Value.ToString();
aussiejmasp
Member
19 Points
110 Posts
Passing a session value to a text box on a pop up page
Feb 06, 2012 11:26 AM|LINK
I have a grid view (where i view information on potential customers) where once I click on a button beside a specific record, it brings me to a popup form for me to add additional information for the specific potential customer. The only thing is once I click on that button, I want to pass the PotentialCustomerNo and have it displayed in a text box of the same name in the pop up form where I am entering the additional information. How can I do this?
vytautas.ziu...
Contributor
3854 Points
691 Posts
Re: Passing a session value to a text box on a pop up page
Feb 06, 2012 11:28 AM|LINK
That depends on how you open a popup form. Do you use jQuery, some kind of extender or something else?
sunilgurjar
Contributor
2252 Points
478 Posts
Re: Passing a session value to a text box on a pop up page
Feb 06, 2012 11:29 AM|LINK
try this
http://www.aspdotnet-suresh.com/2011/03/how-to-show-modalpopup-to-edit-gridview.html
read my blog
http://sunilgurjar.blogspot.com/
aussiejmasp
Member
19 Points
110 Posts
Re: Passing a session value to a text box on a pop up page
Feb 07, 2012 10:20 AM|LINK
Ok i tried it so far. when i run it however, I get the following exception:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 32: { Line 33: Button btndetails = sender as Button; Line 34: GridViewRow gvrow = new GridViewRow(); Line 35: gvrow = (GridViewRow)btndetails.NamingContainer;
Please advise.
eidand
Member
522 Points
146 Posts
Re: Passing a session value to a text box on a pop up page
Feb 07, 2012 12:01 PM|LINK
Since you're not posting any html / code i'll assume you didn't build your page corectly.
The NamingContainer should contain its parent container which should be your GrdiViewRow. This assumes you have a GridView and not something else. Then your button should be part of that GridViewRow.
Run your debugger and see what's in btndetails.NamingContainer before trying to cast that as a GridViewRow.
aussiejmasp
Member
19 Points
110 Posts
Re: Passing a session value to a text box on a pop up page
Feb 08, 2012 10:58 AM|LINK
Ok I realised that for the btndetails variable, I declared it as the wrong type. It should have been a LinkButton. After I do that however, I get another exception. Please see below:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Source Error:
Line 33: LinkButton btndetails = sender as LinkButton; Line 34: GridViewRow gvrow = (GridViewRow)btndetails.NamingContainer; Line 35: potentialCustNoLabelID.Text = Potentialcustgrid2.DataKeys[gvrow.RowIndex].Value.ToString();
aussiejmasp
Member
19 Points
110 Posts
Re: Passing a session value to a text box on a pop up page
Feb 26, 2012 04:44 PM|LINK
BTW i must say thanks.