I'm using a SqlDataSource to populate my GridView, because the two seem to be so tightly coupled together. Since this grid shows results of a search, I have a dynamic sql string being written in my codebehind that references parameters I pass in, such as below:
sdsResults.SelectParameters.Add("CodeID", TypeCode.String, strCodeID)
My problem is that the CodeID field is a varchar field. As you may have experienced, passing in an nvarchar field to be evaluated against a varchar field can be very detrimental to sql performance. However, SelectParameters.Add only takes in TypeCode types, which seems to only give me the unicode TypeCode.String as my viable option.
How do I force my SqlDataSource to use varchars? I can't change the datatype at this point--it's a main key of a large 10 year old app, and frankly, varchar is right for the application.