EZ1 get datasource name of e.Item.Cells(i) in datagrid

having trouble setting a row to session by data source name of the cell.
just need to replace "DATASOURCE" in the section below to reflect 'i' as data sourcename

Thanks

Private Sub grdks_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles grdks.ItemCommand
        If e.Item.ItemType = ListItemType.Pager Or e.Item.ItemType = ListItemType.Header Then
            Exit Sub
        End If
            Dim i As Integer
            For i = 0 To grdks.Items.Count - 1
                Session(DATASOURCENAME) = e.Item.Cells(i).Text
            Next i
end sub
LVL 7
5thcavAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

irps20001Commented:
Hi
I understand this as you want to store a particular row data into session. If iam correct, why dont you use an arraylist and store it in a session later if u really want.
For ex:
[CODE]
Private dataSourceArrayList As New ArrayList
Private Sub grdks_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles grdks.ItemCommand
        If e.Item.ItemType = ListItemType.Pager Or e.Item.ItemType = ListItemType.Header Then
            Exit Sub
        End If
        Dim i As Integer
        For i = 0 To grdks.Items.Count - 1
            dataSourceArrayList.Add(e.Item.Cells(i).Text)
            'Session(DATASOURCENAME) = e.Item.Cells(i).Text
        Next i
    End Sub
[/CODE]
Further if you want to do some operations with the data that is captured into arraylist, can be used as per your requirement.

This is an alternate solution for your problem, There could be many solutions. Do let me know if you are looking for something more so that i will try to give alternate solutions.

HTH
Happy Programming
Rana
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
5thcavAuthor Commented:
Hi Rana

I thought about an array, i thought sessions would be just as good seeing im not going to have to loop through the data after i fill it,, so it seemed and array was an overkill,,, im guessing the sesion data would be less work on the server,..

ney my trouble was, i can t   replace the DATASOURCENAME on this statement > Session(DATASOURCENAME) with the actual name of the datasource.

so my loop will make:
Session(Item.Cells(i).????? ) = e.Item.Cells(i).Text

Session("ID") = e.Item.Cells(i).Text
Session("Fname") = e.Item.Cells(i).Text
Session("Lname") = e.Item.Cells(i).Text

thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.