Hi, does anyone know why o == null?!
protected void ShowProjectsGridView_SelectedIndexChange
d(object
sender, EventArgs e) {
Object o = ProjectsGridView.SelectedRow.DataItem;
//...
}
Thanks,
Etam."etam" <odwrotnie@.gmail.com> wrote in message
news:1180188109.472898.157020@.k79g2000hse.googlegroups.com...
> Hi, does anyone know why o == null?!
> protected void ShowProjectsGridView_SelectedIndexChange
d(object
> sender, EventArgs e) {
> Object o = ProjectsGridView.SelectedRow.DataItem;
> //...
> }
> Thanks,
> Etam.
Have you forgotten to specify the DataKeyNames property in the
<asp:GridView> tag...?
http://www.markrae.net
Mark Rae napisa (a):
> Have you forgotten to specify the DataKeyNames property in the
> <asp:GridView> tag...?
No, it is set to "id".
"etam" <odwrotnie@.gmail.com> wrote in message
news:1180211758.127237.49550@.o5g2000hsb.googlegroups.com...
> Mark Rae napisa (a):
> No, it is set to "id".
?
You actually have a field in your database table called 'id'...?
http://www.markrae.net
On 26 Maj, 22:53, "Mark Rae" <m...@.markNOSPAMrae.net> wrote:
> You actually have a field in your database table called 'id'...?
Yes :). Strange for me is that
Int64 id = (Int64)ProjectsGridView.SelectedDataKey.Value;
is OK :/.
Regards,
Etam.
DataItem property is available only in RowDataBound. It makes a lot of sense
if you think about it since this event is the only time when grid items
actually meet their datasources.
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"etam" <odwrotnie@.gmail.com> wrote in message
news:1180188109.472898.157020@.k79g2000hse.googlegroups.com...
> Hi, does anyone know why o == null?!
> protected void ShowProjectsGridView_SelectedIndexChange
d(object
> sender, EventArgs e) {
> Object o = ProjectsGridView.SelectedRow.DataItem;
> //...
> }
> Thanks,
> Etam.
>
On 27 Maj, 09:30, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@.mMvVpPsS.org> wrote:
> DataItem property is available only in RowDataBound. It makes a lot of sen
se
> if you think about it since this event is the only time when grid items
> actually meet their datasources.
So what for is the DataItem property in GridViewRow?
Regards,
Etam.
It does get the data object that supplies data to the rows but it does it
only during the RowDataBound event. In all other times it returns null.
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"etam" <odwrotnie@.gmail.com> wrote in message
news:1180253280.035540.8080@.h2g2000hsg.googlegroups.com...
> On 27 Maj, 09:30, "Eliyahu Goldin"
> <REMOVEALLCAPITALSeEgGoldD...@.mMvVpPsS.org> wrote:
> So what for is the DataItem property in GridViewRow?
> Regards,
> Etam.
>
On 27 Maj, 11:34, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@.mMvVpPsS.org> wrote:
> It does get the data object that supplies data to the rows but it does it
> only during the RowDataBound event. In all other times it returns null.
Thanks! It explains a lot ;). Could You give me a link where can I
read about it from?
Regards,
Etam.
msdn library is good enough:
http://msdn2.microsoft.com/en-us/li... />
aitem.aspx
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"etam" <odwrotnie@.gmail.com> wrote in message
news:1180262101.295257.253430@.w5g2000hsg.googlegroups.com...
> On 27 Maj, 11:34, "Eliyahu Goldin"
> <REMOVEALLCAPITALSeEgGoldD...@.mMvVpPsS.org> wrote:
> Thanks! It explains a lot ;). Could You give me a link where can I
> read about it from?
> Regards,
> Etam.
>
Wednesday, March 28, 2012
Why it is null?
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment