changing data before sending to datagrid

geocodes

New Member
IS there a way to change the wording of some data before sending to the datagrid. What I mean is I have a database field called dept which has the shortname version of the dept. Ex. IT i want to change to Information Technology before displaying to the user. There is not much data showing (max 6 rec on a page). I am looking for the best way to accomplish this.<BR><BR>MattIf I understand correctly, you have a database field named Ex.IT.<BR>You should be able to set the datagrid HeaderText property to<BR>Information Technology as follows:<BR><BR><ASP:BoundColumn HeaderText = "Information Technology" DataField = "Ex.IT" /><BR><BR>This would give you the heading you want but still bind the correct dataset column.<BR><BR>Tom Thmm I was looking to change the individual items themselves but I do not think you can do that with a datagrid. The heading is going to be called Department.<BR><BR>Mattif i understand your question, you would like to manipulate some data in 1 of your columns on each row.. maybe with select case or something..<BR><BR>I'm by no means an expert.. but to me, the easiest way would be to capture your dataset/recordset to an array, loop through the array making your changes.. then bind the array to your datagrid..<BR><BR>i'm sure there's a better way.. but to my < expert brain, that seems the easiest..<BR><BR>If what you want to do is change a value in your dataset before binding it to the datagrid, then you can:<BR><BR>1. Load the dataset and table from your database.<BR>2. Loop through each item in the column you want to change<BR> using a for/next loop. If the item selected equals to<BR> the one you want to change (Ex.IT) then you can change<BR> it in the dataset before binding to the grid. If you <BR> DO NOT want these changes reflected back in you database<BR> don't do any updates.<BR><BR>Here's a basic loop:<BR><BR>For i = 0 to objDataSet.Tables("Scores").Rows.Count -1<BR><BR> intSearch = objDataSet.Tables("Scores").Rows(i)(0)<BR><BR> If intSearch = "Ex.IT" then<BR> objDataSet.Tables("Scores").Rows(i)(0)= "IT Department"<BR> End If<BR>Next<BR><BR>MyDataGrid.DataSource = ObjDataSet("Scores")<BR>MyDataGrid.DataBind()<BR><BR>If you have multiple names you want to change in the column, then<BR>a Select Case statement could be used instead of the if/then.<BR><BR>I hope this helps with what you're trying to do.<BR><BR>Tom T
 
Back
Top