Could someone suggest which way to go with below issue? I'd like to customize a gridview created with below query:
Dim AttList = From myList In myDB.Table1 _
Where myList.CId = (Request.QueryString("CID")) _
Select New With { _
myList.Person.NWZ, _
myList.Person.FirstName, _
myList.Person.LastName _
}
grdList.DataSource = AttList
grdList.DataBind()
I'd like to do two customizations:
1. Add a column with an index to the Gridview
2. Modify in VB content of that gridview before displaying or results returned by the query
I tried putting:
For Each SingleAtt In AttList
SingleAtt.NWZ = 1
Next
before grdList.DataSource = AttList , but that didn't change anything.
Is there any way to make modifications in a list of elements returned by the SQL query?
Just first create a whole complete anoymous class model collection,and then bind to the GridView(Please set your GridView's AutoGeneratedColumns=True),every basic type would be recognized automatically and show what you want……
Sample:
Dim AttList = From myList In myDB.Table1 _
Where myList.CId = (Request.QueryString("CID")) _
Select New With { _
myList.Person.NWZ, _
myList.Person.FirstName, _
myList.Person.LastName _
}
For Each SingleAtt In AttList
SingleAtt.NWZ = 1
Next
grdList.DataSource = AttList
grdList.DataBind()
gadujr
Member
14 Points
21 Posts
[VB] Customizing Gridview
Apr 09, 2012 09:19 PM|LINK
Hi,
Could someone suggest which way to go with below issue? I'd like to customize a gridview created with below query:
Dim AttList = From myList In myDB.Table1 _
Where myList.CId = (Request.QueryString("CID")) _
Select New With { _
myList.Person.NWZ, _
myList.Person.FirstName, _
myList.Person.LastName _
}
grdList.DataSource = AttList
grdList.DataBind()
I'd like to do two customizations:
1. Add a column with an index to the Gridview
2. Modify in VB content of that gridview before displaying or results returned by the query
I tried putting:
For Each SingleAtt In AttList
SingleAtt.NWZ = 1
Next
before grdList.DataSource = AttList , but that didn't change anything.
Is there any way to make modifications in a list of elements returned by the SQL query?
Appreciate any suggestions.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: [VB] Customizing Gridview
Apr 11, 2012 01:47 AM|LINK
Hello:)
【Solutions】
Just first create a whole complete anoymous class model collection,and then bind to the GridView(Please set your GridView's AutoGeneratedColumns=True),every basic type would be recognized automatically and show what you want……
Sample:
Dim AttList = From myList In myDB.Table1 _ Where myList.CId = (Request.QueryString("CID")) _ Select New With { _ myList.Person.NWZ, _ myList.Person.FirstName, _ myList.Person.LastName _ } For Each SingleAtt In AttList SingleAtt.NWZ = 1 Next grdList.DataSource = AttList grdList.DataBind()