<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Data Presentation Controls</title><link>http://forums.asp.net/24.aspx</link><description>ASP.NET data-bound controls such as the DataGrid, DataList, GridView, FormView, DetailsView, and Repeater Controls.  &lt;a href="http://aspadvice.com/SignUp/list.aspx?l=23&amp;c=17" target="_blank"&gt;Email List&lt;/a&gt;</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Storing the Key from GridView</title><link>http://forums.asp.net/thread/1331758.aspx</link><pubDate>Tue, 04 Jul 2006 06:41:48 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1331758</guid><dc:creator>ReyN</dc:creator><author>ReyN</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1331758.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=24&amp;PostID=1331758</wfw:commentRss><description>&lt;p&gt;&lt;font face=Verdana size=2&gt;with &lt;strong&gt;DataKeyNames&lt;/strong&gt;, you can simply use &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;font face=Verdana size=2&gt;GridView.SelectedValue &lt;img src="/emoticons/emotion-5.gif" alt="Wink" /&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;</description></item><item><title>Re: Storing the Key from GridView</title><link>http://forums.asp.net/thread/1331543.aspx</link><pubDate>Mon, 03 Jul 2006 22:22:36 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1331543</guid><dc:creator>crippsy</dc:creator><author>crippsy</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1331543.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=24&amp;PostID=1331543</wfw:commentRss><description>&lt;p&gt;Got there in the end thanks to your help. I was using the Findcontrol command, but was doing this in the Master document and not the child document. I have now moved the source to the child document and this&amp;nbsp;now works well.&lt;/p&gt;
&lt;p&gt;Many thanks again&lt;/p&gt;
&lt;p&gt;Simon&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Storing the Key from GridView</title><link>http://forums.asp.net/thread/1330567.aspx</link><pubDate>Sun, 02 Jul 2006 19:07:54 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1330567</guid><dc:creator>e_screw</dc:creator><author>e_screw</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1330567.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=24&amp;PostID=1330567</wfw:commentRss><description>Hi,&lt;br /&gt;When you were using MasterPages, you need to find the GridView control and its not that you declare a variable as GridView. &lt;br /&gt;Have a look at this article, &lt;a href="http://west-wind.com/weblog/posts/5127.aspx"&gt;MasterPages and FindControl()&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;You can have multiple datakeys defined for a GridView.&lt;br /&gt;&lt;br /&gt;Thanks&lt;br /&gt;</description></item><item><title>Re: Storing the Key from GridView</title><link>http://forums.asp.net/thread/1330563.aspx</link><pubDate>Sun, 02 Jul 2006 18:54:28 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1330563</guid><dc:creator>crippsy</dc:creator><author>crippsy</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1330563.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=24&amp;PostID=1330563</wfw:commentRss><description>&lt;p&gt;Thanks for the advice and such a quick responce.&lt;/p&gt;
&lt;p&gt;First of all I set&amp;nbsp;I set &lt;/p&gt;&lt;font size=2&gt;
&lt;p&gt;NewText = GridView1.SelectedDataKey.Values&lt;/p&gt;
&lt;p&gt;and I get an error that &lt;font color=#ff0000&gt;GridView1 is not Declared,&lt;/font&gt; so in the same sub I set &lt;/p&gt;&lt;font color=#0000ff size=2&gt;
&lt;p&gt;Dim&lt;/p&gt;&lt;/font&gt;&lt;font size=2&gt; Gridview1 &lt;/font&gt;&lt;font color=#0000ff size=2&gt;As&lt;/font&gt;&lt;font size=2&gt; GridView&lt;/font&gt;
&lt;p&gt;&lt;font size=2&gt;However it now warns me that &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size=2&gt;&lt;font color=#ff0000&gt;Variable 'GridView1' is used befor it has been assigned a value. A null reference exception could result at runtime&lt;/font&gt;.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size=2&gt;Which it does.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size=2&gt;Could part of the issue be that it is set in the Master page? also another quirk but probably not affect this issue is that this GridView has 2 dataKeys set as it is using two joined tables.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size=2&gt;Any further views,?&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size=2&gt;Thanks in advance.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size=2&gt;&amp;nbsp;&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;</description></item><item><title>Re: Storing the Key from GridView</title><link>http://forums.asp.net/thread/1330540.aspx</link><pubDate>Sun, 02 Jul 2006 17:05:35 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1330540</guid><dc:creator>e_screw</dc:creator><author>e_screw</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1330540.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=24&amp;PostID=1330540</wfw:commentRss><description>Hi,&lt;br /&gt;Set the DataKeyNames of the GridView to the primaryKey of your data, so you can access the value of the selected DataKey in your code this way..&lt;br /&gt;&lt;br /&gt;GridView1.SelectedDataKey.Value&lt;br /&gt;&lt;br /&gt;Thanks&lt;br /&gt;</description></item><item><title>Storing the Key from GridView</title><link>http://forums.asp.net/thread/1330509.aspx</link><pubDate>Sun, 02 Jul 2006 15:21:36 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1330509</guid><dc:creator>crippsy</dc:creator><author>crippsy</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1330509.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=24&amp;PostID=1330509</wfw:commentRss><description>&lt;p&gt;I am looking to store the value from the selected record in a GridView so that I can Navigate to a new page with this as a session variable.&lt;/p&gt;
&lt;p&gt;I have tried many variations of the code (held in the master page) but get a variation of issue. The simplified version of the code below returns and issue that GridView1 is not declared. As you can see from the Sub my gridview is called Grid view1. If I uncomment the Dim statement for Gridview1 and run the screen i get "&lt;font color=#ff0000&gt;&lt;strong&gt;Exception Details: &lt;/strong&gt;&lt;font face=Arial&gt;System.NullReferenceException: Object reference not set to an instance of an object"&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font color=#0000ff size=2&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;font color=#0000ff size=2&gt;Protected&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font color=#0000ff size=2&gt;Sub&lt;/font&gt;&lt;font size=2&gt; GridView1_SelectedIndexChanged(&lt;/font&gt;&lt;font color=#0000ff size=2&gt;ByVal&lt;/font&gt;&lt;font size=2&gt; sender &lt;/font&gt;&lt;font color=#0000ff size=2&gt;As&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font color=#0000ff size=2&gt;Object&lt;/font&gt;&lt;font size=2&gt;, &lt;/font&gt;&lt;font color=#0000ff size=2&gt;ByVal&lt;/font&gt;&lt;font size=2&gt; e &lt;/font&gt;&lt;font color=#0000ff size=2&gt;As&lt;/font&gt;&lt;font size=2&gt; System.EventArgs)&lt;/font&gt;&lt;/p&gt;&lt;font size=2&gt;&lt;font color=#0000ff size=2&gt;
&lt;p&gt;&lt;font color=#008000&gt;&amp;nbsp;' Dim&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#008000&gt;&lt;font size=2&gt; Gridview1 &lt;/font&gt;&lt;font size=2&gt;As&lt;/font&gt;&lt;font size=2&gt; GridView&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#0000ff size=2&gt;Dim&lt;/font&gt;&lt;font size=2&gt; NewText &lt;/font&gt;&lt;font color=#0000ff size=2&gt;As&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font color=#0000ff size=2&gt;String&lt;/font&gt;&lt;font size=2&gt;
&lt;p&gt;NewText = GridView1.Cells(0)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font size=2&gt;Session(&lt;/font&gt;&lt;font color=#800000 size=2&gt;"Table_ID"&lt;/font&gt;&lt;font size=2&gt;) = NewText
&lt;p&gt;Response.Redirect(&lt;/p&gt;&lt;/font&gt;&lt;font color=#800000 size=2&gt;"../Newpage.aspx"&lt;/font&gt;&lt;font size=2&gt;)
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#0000ff size=2&gt;End&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font color=#0000ff size=2&gt;Sub&lt;/font&gt;
&lt;p&gt;&lt;font color=#0000ff size=2&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;font color=#0000ff size=2&gt;&lt;font color=#000000 size=3&gt;I have also tried variations on what to put in place of the system.EventsArgs and replacing &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;"NewText = &lt;font color=#0000ff&gt;GridView1&lt;/font&gt;.Cells(0)" &lt;/p&gt;
&lt;p&gt;with &lt;/p&gt;
&lt;p&gt;"NewText = &lt;font color=#ff0000&gt;e.item&lt;/font&gt;.Cells(0)"&lt;/p&gt;
&lt;p&gt;&lt;font color=#0000ff size=2&gt;&lt;font color=#000000 size=3&gt;as I have seen e.item in other examples but the item does not seem to be a member of &lt;font size=2&gt;System.EventArgs or the other variations I use (i.e &lt;font size=2&gt;GridViewCommandEventArgs)&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size=2&gt;However DataGridItemEventArgs does allow e.items.Cells(0) but returns the error that it&amp;nbsp;" &lt;font face=Arial&gt;&lt;font color=#ff0000&gt;does not have the same signature as delegate 'Delegate Sub EventHandler(sender As Object, e As System.&lt;/font&gt;&lt;font color=#ff0000&gt;EventArgs)&lt;/font&gt; "&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size=2&gt;&lt;font face=Arial&gt;Any advice would be most greatfully recieved&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size=2&gt;&lt;font face=Arial&gt;&lt;/font&gt;&amp;nbsp;&lt;/font&gt;&lt;/p&gt;</description></item></channel></rss>