Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Accessing GridViewRow.DataItem outside of GridView databinding events

Reply
Thread Tools

Accessing GridViewRow.DataItem outside of GridView databinding events

 
 
Andy B.
Guest
Posts: n/a
 
      07-03-2009

How do you access GridViewRow.DataItem without having to get to it inside
GridView events? I have a particular thing I am trying to do and forcing it
to be done inside gridviews events wont work.


 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      07-03-2009
use the GridView.DataSource, this is how it accesses it.


-- bruce (sqlwork.com)

Andy B. wrote:
> How do you access GridViewRow.DataItem without having to get to it inside
> GridView events? I have a particular thing I am trying to do and forcing it
> to be done inside gridviews events wont work.
>
>

 
Reply With Quote
 
 
 
 
Andy B.
Guest
Posts: n/a
 
      07-03-2009

Can you give me a simple example? This is what I have going on. There is a
Wizard on a WebUser control. It has a GridView on step 1 that uses a List(Of
HeadlinesInfo) as its DataSource. The object HeadlinesInfo is a custom
business object. In the GridView, I have a column of CheckBoxes for
selecting the GridView rows. When I press next button, I want to loop
through the rows and put the datasource objects related to the checked
GridViewRows in another List(Of HeadlinesInfo) list. Would there be any way
of doing something like this? I have tried just about all day and can't
figure it out yet. Thanks for the help.
"bruce barker" <(E-Mail Removed)> wrote in message
news:eUyNJDC$(E-Mail Removed)...
> use the GridView.DataSource, this is how it accesses it.
>
>
> -- bruce (sqlwork.com)
>
> Andy B. wrote:
>> How do you access GridViewRow.DataItem without having to get to it inside
>> GridView events? I have a particular thing I am trying to do and forcing
>> it to be done inside gridviews events wont work.



 
Reply With Quote
 
Mark Stevens
Guest
Posts: n/a
 
      07-04-2009
I think this article contains enough information to show you process
the rows with the checked boxes:

http://www.4guysfromrolla.com/articles/053106-1.aspx

I used this article to help me work out how to do exactly the sort of
thing you are trying to do in the app my team develops.

Cheers,
Mark

On Fri, 3 Jul 2009 17:38:53 -0400, "Andy B." <(E-Mail Removed)>
wrote:

>
>Can you give me a simple example? This is what I have going on. There is a
>Wizard on a WebUser control. It has a GridView on step 1 that uses a List(Of
>HeadlinesInfo) as its DataSource. The object HeadlinesInfo is a custom
>business object. In the GridView, I have a column of CheckBoxes for
>selecting the GridView rows. When I press next button, I want to loop
>through the rows and put the datasource objects related to the checked
>GridViewRows in another List(Of HeadlinesInfo) list. Would there be any way
>of doing something like this? I have tried just about all day and can't
>figure it out yet. Thanks for the help.
>"bruce barker" <(E-Mail Removed)> wrote in message
>news:eUyNJDC$(E-Mail Removed)...
>> use the GridView.DataSource, this is how it accesses it.
>>
>>
>> -- bruce (sqlwork.com)
>>
>> Andy B. wrote:
>>> How do you access GridViewRow.DataItem without having to get to it inside
>>> GridView events? I have a particular thing I am trying to do and forcing
>>> it to be done inside gridviews events wont work.

>

--
|\ _,,,---,,_ A picture used to be worth a
ZZZzzz /,`.-'`' -. ;-;;, thousand words - then along
|,4- ) )-,_. ,\ ( `'-' came television!
'---''(_/--' `-'\_)

Mark Stevens (mark at thepcsite fullstop co fullstop uk)

This message is provided "as is".
 
Reply With Quote
 
Andy B.
Guest
Posts: n/a
 
      07-04-2009

I can do the checkboxes without a problem. It's the accessing the
Row.DataItem or DataSource data related to the checked boxes that I have
problems with.
"Mark Stevens" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
>I think this article contains enough information to show you process
> the rows with the checked boxes:
>
> http://www.4guysfromrolla.com/articles/053106-1.aspx
>
> I used this article to help me work out how to do exactly the sort of
> thing you are trying to do in the app my team develops.
>
> Cheers,
> Mark
>
> On Fri, 3 Jul 2009 17:38:53 -0400, "Andy B." <(E-Mail Removed)>
> wrote:
>
>>
>>Can you give me a simple example? This is what I have going on. There is a
>>Wizard on a WebUser control. It has a GridView on step 1 that uses a
>>List(Of
>>HeadlinesInfo) as its DataSource. The object HeadlinesInfo is a custom
>>business object. In the GridView, I have a column of CheckBoxes for
>>selecting the GridView rows. When I press next button, I want to loop
>>through the rows and put the datasource objects related to the checked
>>GridViewRows in another List(Of HeadlinesInfo) list. Would there be any
>>way
>>of doing something like this? I have tried just about all day and can't
>>figure it out yet. Thanks for the help.
>>"bruce barker" <(E-Mail Removed)> wrote in message
>>news:eUyNJDC$(E-Mail Removed)...
>>> use the GridView.DataSource, this is how it accesses it.
>>>
>>>
>>> -- bruce (sqlwork.com)
>>>
>>> Andy B. wrote:
>>>> How do you access GridViewRow.DataItem without having to get to it
>>>> inside
>>>> GridView events? I have a particular thing I am trying to do and
>>>> forcing
>>>> it to be done inside gridviews events wont work.

>>

> --
> |\ _,,,---,,_ A picture used to be worth a
> ZZZzzz /,`.-'`' -. ;-;;, thousand words - then along
> |,4- ) )-,_. ,\ ( `'-' came television!
> '---''(_/--' `-'\_)
>
> Mark Stevens (mark at thepcsite fullstop co fullstop uk)
>
> This message is provided "as is".



 
Reply With Quote
 
Mark Stevens
Guest
Posts: n/a
 
      07-04-2009
Do you mean something like the following:

foreach (GridViewRow row in gridView)
{
CheckBox cd;

cb = (CheckBox) row.FindControl("CheckBoxName");
if ((cb != null) && cb.Checked)
{
int id;

id = row.Cells[0].Text;
}
}

This assumes that the id field is in column 0 and that the column has
been made visible.

Cheers,
Mark


On Sat, 4 Jul 2009 08:24:38 -0400, "Andy B." <(E-Mail Removed)>
wrote:

>I can do the checkboxes without a problem. It's the accessing the
>Row.DataItem or DataSource data related to the checked boxes that I have
>problems with.
>"Mark Stevens" <(E-Mail Removed)> wrote in message
>news(E-Mail Removed).. .
>>I think this article contains enough information to show you process
>> the rows with the checked boxes:
>>
>> http://www.4guysfromrolla.com/articles/053106-1.aspx
>>
>> I used this article to help me work out how to do exactly the sort of
>> thing you are trying to do in the app my team develops.
>>
>> Cheers,
>> Mark
>>
>> On Fri, 3 Jul 2009 17:38:53 -0400, "Andy B." <(E-Mail Removed)>
>> wrote:
>>
>>>
>>>Can you give me a simple example? This is what I have going on. There is a
>>>Wizard on a WebUser control. It has a GridView on step 1 that uses a
>>>List(Of
>>>HeadlinesInfo) as its DataSource. The object HeadlinesInfo is a custom
>>>business object. In the GridView, I have a column of CheckBoxes for
>>>selecting the GridView rows. When I press next button, I want to loop
>>>through the rows and put the datasource objects related to the checked
>>>GridViewRows in another List(Of HeadlinesInfo) list. Would there be any
>>>way
>>>of doing something like this? I have tried just about all day and can't
>>>figure it out yet. Thanks for the help.
>>>"bruce barker" <(E-Mail Removed)> wrote in message
>>>news:eUyNJDC$(E-Mail Removed)...
>>>> use the GridView.DataSource, this is how it accesses it.
>>>>
>>>>
>>>> -- bruce (sqlwork.com)
>>>>
>>>> Andy B. wrote:
>>>>> How do you access GridViewRow.DataItem without having to get to it
>>>>> inside
>>>>> GridView events? I have a particular thing I am trying to do and
>>>>> forcing
>>>>> it to be done inside gridviews events wont work.
>>>

>> --
>> |\ _,,,---,,_ A picture used to be worth a
>> ZZZzzz /,`.-'`' -. ;-;;, thousand words - then along
>> |,4- ) )-,_. ,\ ( `'-' came television!
>> '---''(_/--' `-'\_)
>>
>> Mark Stevens (mark at thepcsite fullstop co fullstop uk)
>>
>> This message is provided "as is".

>

--
|\ _,,,---,,_ A picture used to be worth a
ZZZzzz /,`.-'`' -. ;-;;, thousand words - then along
|,4- ) )-,_. ,\ ( `'-' came television!
'---''(_/--' `-'\_)

Mark Stevens (mark at thepcsite fullstop co fullstop uk)

This message is provided "as is".
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Databinding expressions are only supported on objects that have a DataBinding event jobs ASP .Net 0 09-25-2007 11:54 PM
help with pix inside->outside + dmz->outside + inside->outside->dmz Jack Cisco 0 09-19-2007 01:57 AM
Gridview encoding, or how to run commands before gridview's default databinding, or, how do I disable default databinding at all? Sergei Shelukhin ASP .Net 1 11-12-2006 01:43 PM
Events Events Events Please Help Chris ASP .Net Web Controls 0 08-30-2005 08:21 PM
DataGrid Custom Column Error when DataBinding "does not contain a definition for 'DataBinding'" Earl Teigrob ASP .Net Datagrid Control 1 03-01-2004 04:52 AM



Advertisments