C# NullReference, What do I Need to Initialize? [duplicate]2019 Community Moderator ElectionWhat is a NullReferenceException, and how do I fix it?How do I calculate someone's age in C#?What is the difference between String and string in C#?What does the [Flags] Enum Attribute mean in C#?Hidden Features of C#?Cast int to enum in C#How do I enumerate an enum in C#?What is the best way to iterate over a dictionary?What are the correct version numbers for C#?What do two question marks together mean in C#?Exception is System.Data.SqlClient.SqlException: Incorrect syntax near '9988'
Are small insurances worth it?
Why do phishing e-mails use faked e-mail addresses instead of the real one?
Doubts in understanding some concepts of potential energy
Which classes are needed to have access to every spell in the PHB?
Recommendation letter by significant other if you worked with them professionally?
Why does liquid water form when we exhale on a mirror?
how to modify custom status text color in UI component grid magento 2?
Can we track matter through time by looking at different depths in space?
Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?
Source permutation
Does a difference of tense count as a difference of meaning in a minimal pair?
Street obstacles in New Zealand
Was it really inappropriate to write a pull request for the company I interviewed with?
I can't die. Who am I?
Outlet with 3 sets of wires
Doesn't allowing a user mode program to access kernel space memory and execute the IN and OUT instructions defeat the purpose of having CPU modes?
Does the US political system, in principle, allow for a no-party system?
How does Ehrenfest's theorem apply to the quantum harmonic oscillator?
Minimizing with differential evolution
What materials can be used to make a humanoid skin warm?
Is it a Cyclops number? "Nobody" knows!
Can I negotiate a patent idea for a raise, under French law?
Is divide-by-zero a security vulnerability?
From an axiomatic set theoric approach why can we take uncountable unions?
C# NullReference, What do I Need to Initialize? [duplicate]
2019 Community Moderator ElectionWhat is a NullReferenceException, and how do I fix it?How do I calculate someone's age in C#?What is the difference between String and string in C#?What does the [Flags] Enum Attribute mean in C#?Hidden Features of C#?Cast int to enum in C#How do I enumerate an enum in C#?What is the best way to iterate over a dictionary?What are the correct version numbers for C#?What do two question marks together mean in C#?Exception is System.Data.SqlClient.SqlException: Incorrect syntax near '9988'
This question already has an answer here:
What is a NullReferenceException, and how do I fix it?
31 answers
Newbie question: What exactly needs to be initialized to prevent a NullReferenceException? I don't understand what the variable is. What object reference do I need to set to an instance of what object? Thank you!
.aspx
<p>
<asp:GridView ID="gvConvo" runat="server" AutoGenerateColumns="False" OnSelectedIndexChanged="gvConvo_SelectedIndexChanged">
<Columns>
<asp:TemplateField HeaderText="ID">
<ItemTemplate>
<asp:LinkButton ID="lbtnConvo" OnClick="lbtnConvo_Click" Text='<%#Eval("ConvoUID") %>' runat="server">LinkButton</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Convo" HeaderText="Convo" />
<asp:BoundField DataField="ConvoDate" HeaderText="Date" />
<asp:BoundField DataField="ConvoDesc" HeaderText="Description" />
<asp:BoundField DataField="ConvoType" HeaderText="Type" />
<asp:BoundField DataField="MediaSource" HeaderText="Media Source" />
</Columns>
</asp:GridView>
</p>
<p>
</p>
<p>
Convo:
<asp:TextBox ID="txtConvoSelection" runat="server" OnTextChanged="txtConvoSelection_TextChanged"></asp:TextBox>
</p>
.cs
protected void Page_Load(object sender, EventArgs e)
if (!IsPostBack)
string PersuasionDBCon = ConfigurationManager.ConnectionStrings["PersuasionDBCon"].ConnectionString;
using (SqlConnection con = new SqlConnection(PersuasionDBCon))
SqlCommand cmd = new SqlCommand("GetConvo", con);
cmd.CommandType = CommandType.StoredProcedure;
con.Open();
gvConvo.DataSource = cmd.ExecuteReader();
gvConvo.DataBind();
protected void lbtnConvo_Click(object sender, EventArgs e)
txtConvoSelection.Text = gvConvo.SelectedRow.Cells[1].Text;
protected void BtnSaveQuote_Click(object sender, EventArgs e)
protected void gvConvo_SelectedIndexChanged(object sender, EventArgs e)
protected void txtConvoSelection_TextChanged(object sender, EventArgs e)
This is the line that's throwing the exception:
txtConvoSelection.Text = gvConvo.SelectedRow.Cells[1].Text;
c# asp.net
marked as duplicate by Uwe Keim
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Mar 7 at 5:31
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
What is a NullReferenceException, and how do I fix it?
31 answers
Newbie question: What exactly needs to be initialized to prevent a NullReferenceException? I don't understand what the variable is. What object reference do I need to set to an instance of what object? Thank you!
.aspx
<p>
<asp:GridView ID="gvConvo" runat="server" AutoGenerateColumns="False" OnSelectedIndexChanged="gvConvo_SelectedIndexChanged">
<Columns>
<asp:TemplateField HeaderText="ID">
<ItemTemplate>
<asp:LinkButton ID="lbtnConvo" OnClick="lbtnConvo_Click" Text='<%#Eval("ConvoUID") %>' runat="server">LinkButton</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Convo" HeaderText="Convo" />
<asp:BoundField DataField="ConvoDate" HeaderText="Date" />
<asp:BoundField DataField="ConvoDesc" HeaderText="Description" />
<asp:BoundField DataField="ConvoType" HeaderText="Type" />
<asp:BoundField DataField="MediaSource" HeaderText="Media Source" />
</Columns>
</asp:GridView>
</p>
<p>
</p>
<p>
Convo:
<asp:TextBox ID="txtConvoSelection" runat="server" OnTextChanged="txtConvoSelection_TextChanged"></asp:TextBox>
</p>
.cs
protected void Page_Load(object sender, EventArgs e)
if (!IsPostBack)
string PersuasionDBCon = ConfigurationManager.ConnectionStrings["PersuasionDBCon"].ConnectionString;
using (SqlConnection con = new SqlConnection(PersuasionDBCon))
SqlCommand cmd = new SqlCommand("GetConvo", con);
cmd.CommandType = CommandType.StoredProcedure;
con.Open();
gvConvo.DataSource = cmd.ExecuteReader();
gvConvo.DataBind();
protected void lbtnConvo_Click(object sender, EventArgs e)
txtConvoSelection.Text = gvConvo.SelectedRow.Cells[1].Text;
protected void BtnSaveQuote_Click(object sender, EventArgs e)
protected void gvConvo_SelectedIndexChanged(object sender, EventArgs e)
protected void txtConvoSelection_TextChanged(object sender, EventArgs e)
This is the line that's throwing the exception:
txtConvoSelection.Text = gvConvo.SelectedRow.Cells[1].Text;
c# asp.net
marked as duplicate by Uwe Keim
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Mar 7 at 5:31
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1
EithertxtConvoSelection
is null,gvConvo
is null,SelectedRow
is null, or (less likely, frankly)Cells[1]
is null.
– John
Mar 7 at 5:13
txtConvoSelection is just an empty text box that's waiting to be populated on lbtnConvo_Click. Is that the same as being null? If the value isn't null to start with, what should it be?
– Vesper Annstas
Mar 7 at 5:18
add a comment |
This question already has an answer here:
What is a NullReferenceException, and how do I fix it?
31 answers
Newbie question: What exactly needs to be initialized to prevent a NullReferenceException? I don't understand what the variable is. What object reference do I need to set to an instance of what object? Thank you!
.aspx
<p>
<asp:GridView ID="gvConvo" runat="server" AutoGenerateColumns="False" OnSelectedIndexChanged="gvConvo_SelectedIndexChanged">
<Columns>
<asp:TemplateField HeaderText="ID">
<ItemTemplate>
<asp:LinkButton ID="lbtnConvo" OnClick="lbtnConvo_Click" Text='<%#Eval("ConvoUID") %>' runat="server">LinkButton</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Convo" HeaderText="Convo" />
<asp:BoundField DataField="ConvoDate" HeaderText="Date" />
<asp:BoundField DataField="ConvoDesc" HeaderText="Description" />
<asp:BoundField DataField="ConvoType" HeaderText="Type" />
<asp:BoundField DataField="MediaSource" HeaderText="Media Source" />
</Columns>
</asp:GridView>
</p>
<p>
</p>
<p>
Convo:
<asp:TextBox ID="txtConvoSelection" runat="server" OnTextChanged="txtConvoSelection_TextChanged"></asp:TextBox>
</p>
.cs
protected void Page_Load(object sender, EventArgs e)
if (!IsPostBack)
string PersuasionDBCon = ConfigurationManager.ConnectionStrings["PersuasionDBCon"].ConnectionString;
using (SqlConnection con = new SqlConnection(PersuasionDBCon))
SqlCommand cmd = new SqlCommand("GetConvo", con);
cmd.CommandType = CommandType.StoredProcedure;
con.Open();
gvConvo.DataSource = cmd.ExecuteReader();
gvConvo.DataBind();
protected void lbtnConvo_Click(object sender, EventArgs e)
txtConvoSelection.Text = gvConvo.SelectedRow.Cells[1].Text;
protected void BtnSaveQuote_Click(object sender, EventArgs e)
protected void gvConvo_SelectedIndexChanged(object sender, EventArgs e)
protected void txtConvoSelection_TextChanged(object sender, EventArgs e)
This is the line that's throwing the exception:
txtConvoSelection.Text = gvConvo.SelectedRow.Cells[1].Text;
c# asp.net
This question already has an answer here:
What is a NullReferenceException, and how do I fix it?
31 answers
Newbie question: What exactly needs to be initialized to prevent a NullReferenceException? I don't understand what the variable is. What object reference do I need to set to an instance of what object? Thank you!
.aspx
<p>
<asp:GridView ID="gvConvo" runat="server" AutoGenerateColumns="False" OnSelectedIndexChanged="gvConvo_SelectedIndexChanged">
<Columns>
<asp:TemplateField HeaderText="ID">
<ItemTemplate>
<asp:LinkButton ID="lbtnConvo" OnClick="lbtnConvo_Click" Text='<%#Eval("ConvoUID") %>' runat="server">LinkButton</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Convo" HeaderText="Convo" />
<asp:BoundField DataField="ConvoDate" HeaderText="Date" />
<asp:BoundField DataField="ConvoDesc" HeaderText="Description" />
<asp:BoundField DataField="ConvoType" HeaderText="Type" />
<asp:BoundField DataField="MediaSource" HeaderText="Media Source" />
</Columns>
</asp:GridView>
</p>
<p>
</p>
<p>
Convo:
<asp:TextBox ID="txtConvoSelection" runat="server" OnTextChanged="txtConvoSelection_TextChanged"></asp:TextBox>
</p>
.cs
protected void Page_Load(object sender, EventArgs e)
if (!IsPostBack)
string PersuasionDBCon = ConfigurationManager.ConnectionStrings["PersuasionDBCon"].ConnectionString;
using (SqlConnection con = new SqlConnection(PersuasionDBCon))
SqlCommand cmd = new SqlCommand("GetConvo", con);
cmd.CommandType = CommandType.StoredProcedure;
con.Open();
gvConvo.DataSource = cmd.ExecuteReader();
gvConvo.DataBind();
protected void lbtnConvo_Click(object sender, EventArgs e)
txtConvoSelection.Text = gvConvo.SelectedRow.Cells[1].Text;
protected void BtnSaveQuote_Click(object sender, EventArgs e)
protected void gvConvo_SelectedIndexChanged(object sender, EventArgs e)
protected void txtConvoSelection_TextChanged(object sender, EventArgs e)
This is the line that's throwing the exception:
txtConvoSelection.Text = gvConvo.SelectedRow.Cells[1].Text;
This question already has an answer here:
What is a NullReferenceException, and how do I fix it?
31 answers
c# asp.net
c# asp.net
asked Mar 7 at 5:10
Vesper AnnstasVesper Annstas
238
238
marked as duplicate by Uwe Keim
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Mar 7 at 5:31
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Uwe Keim
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Mar 7 at 5:31
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1
EithertxtConvoSelection
is null,gvConvo
is null,SelectedRow
is null, or (less likely, frankly)Cells[1]
is null.
– John
Mar 7 at 5:13
txtConvoSelection is just an empty text box that's waiting to be populated on lbtnConvo_Click. Is that the same as being null? If the value isn't null to start with, what should it be?
– Vesper Annstas
Mar 7 at 5:18
add a comment |
1
EithertxtConvoSelection
is null,gvConvo
is null,SelectedRow
is null, or (less likely, frankly)Cells[1]
is null.
– John
Mar 7 at 5:13
txtConvoSelection is just an empty text box that's waiting to be populated on lbtnConvo_Click. Is that the same as being null? If the value isn't null to start with, what should it be?
– Vesper Annstas
Mar 7 at 5:18
1
1
Either
txtConvoSelection
is null, gvConvo
is null, SelectedRow
is null, or (less likely, frankly) Cells[1]
is null.– John
Mar 7 at 5:13
Either
txtConvoSelection
is null, gvConvo
is null, SelectedRow
is null, or (less likely, frankly) Cells[1]
is null.– John
Mar 7 at 5:13
txtConvoSelection is just an empty text box that's waiting to be populated on lbtnConvo_Click. Is that the same as being null? If the value isn't null to start with, what should it be?
– Vesper Annstas
Mar 7 at 5:18
txtConvoSelection is just an empty text box that's waiting to be populated on lbtnConvo_Click. Is that the same as being null? If the value isn't null to start with, what should it be?
– Vesper Annstas
Mar 7 at 5:18
add a comment |
2 Answers
2
active
oldest
votes
The code to load the grid is surrounded by an if (!IsPostBack)
block. Guess what? The button click event causes a postback. That's how it runs. And every time you do a postback, the entire page starts over from scratch. That's how HTTP works.
So when you click the button, the data for the grid is not bound, and there is no selected row.
The best fix for this is to make this happen in javascript, rather than C#. Reserve server events for things that really need to do work on the server. That will greatly improve perceived performance (no waiting for round-trips to a potentially-distant server) and help your server scale to handle more users by not needing to rebuild the entire html document for simple changes.
Thanks, Joel! I commented out the <!-- language: c# -->if (!IsPostBack) lines so that the data would be bound when I click the button, but am still getting the same error.
– Vesper Annstas
Mar 7 at 5:26
@VesperAnnstas That's an improvement... but ViewState is restored before the page load phase, so if the data isn't loaded earlier (Pre_Init
is one option) there still can't be a selected row. I updated the answer to suggest a better fix, though.
– Joel Coehoorn
Mar 7 at 5:28
1
Oh: and use backtick characters (just below the escape key) in comments to mark code sections.
– Joel Coehoorn
Mar 7 at 5:30
add a comment |
Index starts from 0gvConvo.SelectedRow.Cells[1]
this field must be null
Try
gvConvo.SelectedRow.Cells[0]
Also check for gvConvo.SelectedRow
may be there is no selected in Grid
Thank you! [1] isn't null, but I did try setting it to [0] just in case. I still get the same error.
– Vesper Annstas
Mar 7 at 5:20
Then gvConvo.SelectedRow must be NULL
– Ashish Sapkale
Mar 7 at 5:45
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The code to load the grid is surrounded by an if (!IsPostBack)
block. Guess what? The button click event causes a postback. That's how it runs. And every time you do a postback, the entire page starts over from scratch. That's how HTTP works.
So when you click the button, the data for the grid is not bound, and there is no selected row.
The best fix for this is to make this happen in javascript, rather than C#. Reserve server events for things that really need to do work on the server. That will greatly improve perceived performance (no waiting for round-trips to a potentially-distant server) and help your server scale to handle more users by not needing to rebuild the entire html document for simple changes.
Thanks, Joel! I commented out the <!-- language: c# -->if (!IsPostBack) lines so that the data would be bound when I click the button, but am still getting the same error.
– Vesper Annstas
Mar 7 at 5:26
@VesperAnnstas That's an improvement... but ViewState is restored before the page load phase, so if the data isn't loaded earlier (Pre_Init
is one option) there still can't be a selected row. I updated the answer to suggest a better fix, though.
– Joel Coehoorn
Mar 7 at 5:28
1
Oh: and use backtick characters (just below the escape key) in comments to mark code sections.
– Joel Coehoorn
Mar 7 at 5:30
add a comment |
The code to load the grid is surrounded by an if (!IsPostBack)
block. Guess what? The button click event causes a postback. That's how it runs. And every time you do a postback, the entire page starts over from scratch. That's how HTTP works.
So when you click the button, the data for the grid is not bound, and there is no selected row.
The best fix for this is to make this happen in javascript, rather than C#. Reserve server events for things that really need to do work on the server. That will greatly improve perceived performance (no waiting for round-trips to a potentially-distant server) and help your server scale to handle more users by not needing to rebuild the entire html document for simple changes.
Thanks, Joel! I commented out the <!-- language: c# -->if (!IsPostBack) lines so that the data would be bound when I click the button, but am still getting the same error.
– Vesper Annstas
Mar 7 at 5:26
@VesperAnnstas That's an improvement... but ViewState is restored before the page load phase, so if the data isn't loaded earlier (Pre_Init
is one option) there still can't be a selected row. I updated the answer to suggest a better fix, though.
– Joel Coehoorn
Mar 7 at 5:28
1
Oh: and use backtick characters (just below the escape key) in comments to mark code sections.
– Joel Coehoorn
Mar 7 at 5:30
add a comment |
The code to load the grid is surrounded by an if (!IsPostBack)
block. Guess what? The button click event causes a postback. That's how it runs. And every time you do a postback, the entire page starts over from scratch. That's how HTTP works.
So when you click the button, the data for the grid is not bound, and there is no selected row.
The best fix for this is to make this happen in javascript, rather than C#. Reserve server events for things that really need to do work on the server. That will greatly improve perceived performance (no waiting for round-trips to a potentially-distant server) and help your server scale to handle more users by not needing to rebuild the entire html document for simple changes.
The code to load the grid is surrounded by an if (!IsPostBack)
block. Guess what? The button click event causes a postback. That's how it runs. And every time you do a postback, the entire page starts over from scratch. That's how HTTP works.
So when you click the button, the data for the grid is not bound, and there is no selected row.
The best fix for this is to make this happen in javascript, rather than C#. Reserve server events for things that really need to do work on the server. That will greatly improve perceived performance (no waiting for round-trips to a potentially-distant server) and help your server scale to handle more users by not needing to rebuild the entire html document for simple changes.
edited Mar 7 at 5:29
answered Mar 7 at 5:20
Joel CoehoornJoel Coehoorn
310k96495730
310k96495730
Thanks, Joel! I commented out the <!-- language: c# -->if (!IsPostBack) lines so that the data would be bound when I click the button, but am still getting the same error.
– Vesper Annstas
Mar 7 at 5:26
@VesperAnnstas That's an improvement... but ViewState is restored before the page load phase, so if the data isn't loaded earlier (Pre_Init
is one option) there still can't be a selected row. I updated the answer to suggest a better fix, though.
– Joel Coehoorn
Mar 7 at 5:28
1
Oh: and use backtick characters (just below the escape key) in comments to mark code sections.
– Joel Coehoorn
Mar 7 at 5:30
add a comment |
Thanks, Joel! I commented out the <!-- language: c# -->if (!IsPostBack) lines so that the data would be bound when I click the button, but am still getting the same error.
– Vesper Annstas
Mar 7 at 5:26
@VesperAnnstas That's an improvement... but ViewState is restored before the page load phase, so if the data isn't loaded earlier (Pre_Init
is one option) there still can't be a selected row. I updated the answer to suggest a better fix, though.
– Joel Coehoorn
Mar 7 at 5:28
1
Oh: and use backtick characters (just below the escape key) in comments to mark code sections.
– Joel Coehoorn
Mar 7 at 5:30
Thanks, Joel! I commented out the <!-- language: c# -->if (!IsPostBack) lines so that the data would be bound when I click the button, but am still getting the same error.
– Vesper Annstas
Mar 7 at 5:26
Thanks, Joel! I commented out the <!-- language: c# -->if (!IsPostBack) lines so that the data would be bound when I click the button, but am still getting the same error.
– Vesper Annstas
Mar 7 at 5:26
@VesperAnnstas That's an improvement... but ViewState is restored before the page load phase, so if the data isn't loaded earlier (
Pre_Init
is one option) there still can't be a selected row. I updated the answer to suggest a better fix, though.– Joel Coehoorn
Mar 7 at 5:28
@VesperAnnstas That's an improvement... but ViewState is restored before the page load phase, so if the data isn't loaded earlier (
Pre_Init
is one option) there still can't be a selected row. I updated the answer to suggest a better fix, though.– Joel Coehoorn
Mar 7 at 5:28
1
1
Oh: and use backtick characters (just below the escape key) in comments to mark code sections.
– Joel Coehoorn
Mar 7 at 5:30
Oh: and use backtick characters (just below the escape key) in comments to mark code sections.
– Joel Coehoorn
Mar 7 at 5:30
add a comment |
Index starts from 0gvConvo.SelectedRow.Cells[1]
this field must be null
Try
gvConvo.SelectedRow.Cells[0]
Also check for gvConvo.SelectedRow
may be there is no selected in Grid
Thank you! [1] isn't null, but I did try setting it to [0] just in case. I still get the same error.
– Vesper Annstas
Mar 7 at 5:20
Then gvConvo.SelectedRow must be NULL
– Ashish Sapkale
Mar 7 at 5:45
add a comment |
Index starts from 0gvConvo.SelectedRow.Cells[1]
this field must be null
Try
gvConvo.SelectedRow.Cells[0]
Also check for gvConvo.SelectedRow
may be there is no selected in Grid
Thank you! [1] isn't null, but I did try setting it to [0] just in case. I still get the same error.
– Vesper Annstas
Mar 7 at 5:20
Then gvConvo.SelectedRow must be NULL
– Ashish Sapkale
Mar 7 at 5:45
add a comment |
Index starts from 0gvConvo.SelectedRow.Cells[1]
this field must be null
Try
gvConvo.SelectedRow.Cells[0]
Also check for gvConvo.SelectedRow
may be there is no selected in Grid
Index starts from 0gvConvo.SelectedRow.Cells[1]
this field must be null
Try
gvConvo.SelectedRow.Cells[0]
Also check for gvConvo.SelectedRow
may be there is no selected in Grid
answered Mar 7 at 5:13
Ashish SapkaleAshish Sapkale
455212
455212
Thank you! [1] isn't null, but I did try setting it to [0] just in case. I still get the same error.
– Vesper Annstas
Mar 7 at 5:20
Then gvConvo.SelectedRow must be NULL
– Ashish Sapkale
Mar 7 at 5:45
add a comment |
Thank you! [1] isn't null, but I did try setting it to [0] just in case. I still get the same error.
– Vesper Annstas
Mar 7 at 5:20
Then gvConvo.SelectedRow must be NULL
– Ashish Sapkale
Mar 7 at 5:45
Thank you! [1] isn't null, but I did try setting it to [0] just in case. I still get the same error.
– Vesper Annstas
Mar 7 at 5:20
Thank you! [1] isn't null, but I did try setting it to [0] just in case. I still get the same error.
– Vesper Annstas
Mar 7 at 5:20
Then gvConvo.SelectedRow must be NULL
– Ashish Sapkale
Mar 7 at 5:45
Then gvConvo.SelectedRow must be NULL
– Ashish Sapkale
Mar 7 at 5:45
add a comment |
1
Either
txtConvoSelection
is null,gvConvo
is null,SelectedRow
is null, or (less likely, frankly)Cells[1]
is null.– John
Mar 7 at 5:13
txtConvoSelection is just an empty text box that's waiting to be populated on lbtnConvo_Click. Is that the same as being null? If the value isn't null to start with, what should it be?
– Vesper Annstas
Mar 7 at 5:18