pythonV
asked on
How do i insert a session variable into gridview
Hello,
I am using ASP.NET and VB.NET, I have a gridview wconnected to a table adapter which returns 3 columns from a database. Column 1 is a feature ID, column 2 is a description and column 3 is detail.
Can I in some way insert a Session variable into a cell in Column 3 where ID = 3 for example.
thanks, much appreciated.
I am using ASP.NET and VB.NET, I have a gridview wconnected to a table adapter which returns 3 columns from a database. Column 1 is a feature ID, column 2 is a description and column 3 is detail.
Can I in some way insert a Session variable into a cell in Column 3 where ID = 3 for example.
thanks, much appreciated.
ASKER
thanks for the response,however, what this is doing is filling all the cells in the column with the same variable. I want just 1 specific cell.
thanks.
thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you, Problem Solved!
If you want to insert that value after the grid has been populated then you need to update the datatable which is the source of the grid. If you are using dataset or datatable to populate the grid, you could insert the value into table and then refresh the grid. For example
dTable.DefaultView.RowFilt er="Featur eID=3"
if dTable.DefaultView.Count>0 then
dTable.DefaultView.Item(0) .Item(2)=" SomeValue"
end if
dTable.DefaultView.RowFilt er=""
dGrid.DataBind()
dTable.DefaultView.RowFilt
if dTable.DefaultView.Count>0
dTable.DefaultView.Item(0)
end if
dTable.DefaultView.RowFilt
dGrid.DataBind()
Glad to help ^^
JINN
JINN
You can interfere anytime in anyway your gridview bind its data, and manipulate the way you want it.
Set the event RowDataBound of your gridview (this event will be fired when datarow is bounded, your can set how you want the specific cell to display. You use VB right? So please take a look at the example:
<asp:gridview id = "myGridView" runat = "server" onRowDataBound = "..." ... > (you better get this on your design)
For more information please visit
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowdatabound.aspx
Hope this helps
JINN
Open in new window