Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 DataRow isn't DataRow.

Author  Topic 

davidshq
Posting Yak Master

119 Posts

Posted - 2005-11-12 : 22:20:37
I wrote an application in ASP.NET 2.0 Beta 2 utilizing VWD Express Beta 2 and SQL Server Express (I believe the June build). The application was complete and working, when I upgraded to ASP.NET 2.0 Final and SQL Server 2005 Express Final, the application broke. I believe the problem is in my stored procedure and its relation to a GridView.
Basically, what occurs is that I have a GridView which calls a stored procedure to populate its rows/columns. Then at the RowDataBound it applies changes to the columns based on the data in each column (e.g. in the Type field the value "1" is converted to "Active Inside" using the e.Row.Cells().Text = ""). But when I upgraded I began getting "out of range errors" - like the Cell didn't exist or something. So I added a If..Then clause around the Select Case statements which did the e.Row.Cells().Text translation. This If..Then clause stated
If e.Row.RowType = DataControlRowType.DataRow Then
(select case statements)
End If.
This allowed the GridView to populate correctly, but it didn't translate Cells(6).Text from numeric 1-10 to strings "Active Inside" "Semi-Active Inside", etc. as it should have. So it seems that for some reason the columns are not being created as DataRows and I can only imagine this has to do with the stored procedure. Any ideas would be helpful. Here is the stored procedure:
select uID as uID2, gID as gID2, LastPlayedDate
into #templastplayed from LastPlayed
where uID LIKE @varUserName
select uID, gID, Popularity as Popularity2
into #temppopularity from GamePopularity
where uID LIKE @varUserName
select * into #results from Game G LEFT JOIN #templastplayed LP ON G.ID=LP.gID2 LEFT JOIN #temppopularity GP ON G.ID=GP.gID
select * from #results
David.

- http://www.civilwarsearch.com/
- http://www.thehungersite.com/
- http://www.grid.org/

davidshq
Posting Yak Master

119 Posts

Posted - 2005-11-14 : 22:56:38
I found the answer to this. Thanks.
David.

- http://www.civilwarsearch.com/
- http://www.thehungersite.com/
- http://www.grid.org/
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-11-15 : 06:06:23
do you mind sharing it?

Go with the flow & have fun! Else fight the flow
Go to Top of Page

davidshq
Posting Yak Master

119 Posts

Posted - 2005-11-15 : 16:44:11
Well, first you need the If e.Row.RowType clause surrounding the statements that change data in the GridView populated rows/columns or else it will try to perform it on header/footer rows which are not DataRows (I think). Secondly, you need to be careful not to say e.Row.Cells(6).ToString instead of e.Row.Cells(6).Text b/c when you do it passes the whole cell rather than just the text. (embarassed)
David.

- http://www.civilwarsearch.com/
- http://www.thehungersite.com/
- http://www.grid.org/
Go to Top of Page
   

- Advertisement -