January 2006 - Posts

european union and microsoft

Perhaps you listen to the news from the "old" continent. Microsoft had to pay 500Mil Euro and must split up the media player from Windows XP. This should ensure that competitors can exist on the market. I would name it the “real” punishment.
Nothing customers have any benefit from.
Newspapers and TV news are full of them and mostly they agree with this decision.

But now comes the top of that. Microsoft wants or must or whatever, give away the source code from windows. I am a longlonglong time developer but I had never the need to look in to the source code. Perhaps I want to copy a piece of it yes, but not for every development job. As I understand development, we are coding around black boxes. And never use undocumented internals of any class or object. At the end almost several hundred peoples on the world really needs to look at parts of the source.
I also guess 99,999999% of the Linux user never have take a look at the source code or recompiles there kernel. So what it is good for.?
My opinion is that the EU is using that as kind of tax to increase the budget. On the other hand they spent a part of this budget to support projects to university’s and others which have the goal to support the Linux development.
I do not agree with this EU act.

Purpose only to tell everybody my opinion.

Posted by preishuber | 5 comment(s)

Masterpage and 2 contentplaceholder:how to communicate?

If you are using master pages and having more than 1 contentplaceholder control you can run into problems like that:

Could not find control 'TextBox1' in ControlParameter 'CompanyName'.

I used a textbox placed in one contentplaceholder to control the dataresults from sqldatasource which is placed in a diffrent contentplaceholder. The visual studio web devleoper wizard, shows in expected matter, in the wizard dialog of sqldatasource WHERE, the complete list of web server controls which are placed in the contentpage. The result looks like:

<SelectParameters>

<asp:ControlParameter ControlID="TextBox1" Name="CompanyName" PropertyName="Text"

Type="String" />

</SelectParameters>

The Textbox and the SQLDatasource are in diffrent controlcontainers. At runtime you get the above error message. To solve the problem you can use a undocumented feature. Include the ID of the parentcontrol in the ControlID of the Controlparameter, in this case the contenplaceholder like that:

<asp:ControlParameter ControlID="ContentPlaceHolder2$TextBox1" Name="CompanyName" PropertyName="Text"

Type="String" />

Now it works.

Have fun.

Posted by preishuber | 8 comment(s)

Somebody have stolen my name: and I am not very amused

A former ASP.Net MVP is using my name for google advertising. He is selling courses which my name in the google adwords list for his company. Try to search for your name and watch the Ads, perhaps somebody is also abusing your name.

http://www.google.de/search?hl=de&q=hannes+preishuber&btnG=Google-Suche&meta=

Result:

Change cell color in gridview depending the inner value

As long time reader ;-) of my blog you know: i am fan of the declarative ASP.NET way ( especialy 2.0) But sometimes i reach the limits. This is e.g. for changing font color in a cell if a value reaches limits (negativ). For this purpose you can use rowcreated event of the gridview. 

  1. take care on rowtype
  2. Findcontrol with e.row.cell(0) or findcontrol
  3. access underlaying data with e.row.dataitem
  4. take care on datatype (this example decimal)

Now the complete code. It based on a templatefield with a label inside.

Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)

If e.Row.RowType = DataControlRowType.DataRow Then
   
Dim lbl As Label = CType(e.Row.FindControl("lblPreis"), Label)
   
If DataBinder.Eval(e.Row.DataItem, "unitprice") < 0D Then
      
lbl.ForeColor = Drawing.Color.Red   End If

End If

End Sub

Hope this helps!

SQLDatasource Controlparameter and the table Null Value problem

I am a fan of codeless databinding. Today i found a problem where i got doubts. A table contains a varchar field where null values are possible. This field is the source for a query with controlparameter.  So you need something like

select * from table1 where field like @par1 +'%'

The ugly thing is that when the "field" contains sometimes no value , means <null>, the record is not in the result set if searching for %. I use this % as defaultvalue to get all records if nothing is in the textbox.

<SelectParameters>

<asp:ControlParameter ControlID="TextBox1" PropertyName="Text" Name="par1"  DefaultValue="%"/>

</SelectParameters>

The workaround is to change the sql command in sqldatasource to

select * from table1 where IsNull(field,'') LIKE IsNull(@par1+'%','%' )  

PS: thanks to Doug Reilly, i got the trick after 2 hours searching from a old posting from him.

Posted by preishuber | 5 comment(s)
More Posts