August 2005 - Posts

FREE IE license till the end of your live

go to www.microsoft.com/ie

i do not understand the hypes, like "free opera" or google mail etc etc

Its only marketing to catch you and get your email to sell you updates

Posted by preishuber | 6 comment(s)

sometimes ASP.NET is more secure

php based german "dotnet magazine" page

Posted by preishuber | 3 comment(s)

attending 5 Developer events in germany

as i am one of the content owners (ASP.NET) for the 5 german  developer conferences end of november,  i am make a little advertising.

Book till august 31 for early bird rate and place on (or all) of the following banners in your blog.

ich bin dabei: ASP konferenz 30.Nov-1.Dez 05 ich bin dabei: Visual Studio konferenz 30.Nov-1.Dez 05 ich bin dabei : Advanced Developers Conferenz 30.Nov-1.Dez 05 ich bin dabei: SQL konferenz 30.Nov-1.Dez 05 ich bin dabei: VBmoves konferenz 30.Nov-1.Dez 05

Posted by preishuber | 2 comment(s)

Missunderstanding of Form Parameter and hidden field

The ASP.NET 2.0 datasource controls support several kind of parameter types to build a where condition in sql select. My try was to use a hidden field to control the input value. Drag & Drop a hidden field from toolbar, fill it with a value

<input id="Hidden1" type=text value="A" />
Then make the databinding with formparmeter ect like

<asp:GridView ID="GridView1" runat="server" DataKeyNames="CustomerID"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="CustomerID" HeaderText="CustomerID" ReadOnly="True" SortExpression="CustomerID" />
<asp:BoundField DataField="CompanyName" HeaderText="CompanyName" SortExpression="CompanyName" />

</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString1 %>"
ProviderName="<%$ ConnectionStrings:NorthwindConnectionString1.ProviderName %>"
SelectCommand="SELECT [CustomerID], [CompanyName], [ContactName] FROM [Customers] WHERE ([CustomerID] LIKE '%' + @CustomerID + '%')"
>
<SelectParameters>
<asp:FormParameter FormField="Hidden1" Name="CustomerID" />
</SelectParameters>
</asp:SqlDataSource>

This doesnt work. Cause i guess this is the common first try i give you in this blog the solution.

1. The input must have the additional attribut "name". Also the formparameter shows "name" as attribute ( and not id)

<input id="Hidden1" name="Hidden1" type=text value="A" />
2. This works only with postback, cause values of HTML elements are only posted on POST

Take care on it :-)

 

 

Posted by preishuber | with no comments

Dropdownlist in a Gridview and the default (null) value problem

To edit a value in ASP.NET 2.0 gridview control you have more options than only a textbox. If you want to choose of a valuelist you can take a dropdownlist. The data of dropdown comes usaly from a table and is placed in the edititemtemplate. A second SQLDatasource control gets the data (here named DSPLZ). The binding is done by selectedValue

<EditItemTemplate>

<asp:SqlDataSource ID="DSKonf" runat="server" ConnectionString="<%$ ConnectionStrings:EventsConnectionString %>"

SelectCommand="SELECT * FROM [AktuelleKonfSteuerung]"></asp:SqlDataSource>

</EditItemTemplate>

<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="DSPLZ" DataTextField="PLZ"

DataValueField="PLZ" SelectedValue='<%# Bind("adressplz") %>'>

</asp:DropDownList> ..

The problems come if the data in the table doesnt fit your data in the PLZ table. Most common reason is that the field contains a NULL Value. Bind fails!

The trick is that you can add items to the dropdown list by declaration. The second part of the trick is to add the DB entrys to the declarated entrys by AppenddataboundItems. Take care to set the value to "" cause the bind gives also back a "" if the field contains NULL

<asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="DSPLZ" DataTextField="PLZ"

DataValueField="PLZ" SelectedValue='<%# Bind("shipPLZ") %>' AppendDataBoundItems=true>

<asp:ListItem Text="wählen" Value=""></asp:ListItem>

</asp:DropDownList>

</asp:TemplateField>

Time to say goodbye to Notepad

I have a task for you. Open Notepad and type some charcters and include some like ä öü ß.

Save it.

Open it with the new VB 2005 helper class My

My.Computer.FileSystem.ReadAllText.....

Send the result string as mail or whatever. The String is not identical with the created textfile.

Reason is that notepad seems to use UTF7 encoding. Standard encoding in .NET is from beginning UTF8. If you use a streamreader you can set the encoding type.

Remember: Notepad can be dangerous cause a wrong encondig can be hidden a long time.

I will not create any template file with notepad any longer.

[UPDATE]

i must be blind. Following up the comments here.
Notepad have a encoding option in the save dialog. I never take care about it, also when i had the problem. But keeping my opinion, encoding of external files is quite a issue

Posted by preishuber | 5 comment(s)

access the data of Gridview in Rowcommand

I am developing several ASP.NET 2.0 application to get expirence from real world problems. Today i found a simple issue realting Gridviews commands. I have a buttonfield in gridview. The attribut commandname is used to make the logic decesion

<asp:ButtonField CommandName="profil" HeaderText="Profil" ShowHeader="True" Text="mail" />

The corresponding event is RowCommand

Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs)

Select Case e.CommandName

Case "profil"

...

Now the question: how to access the values of a special cell?

You have two options. The datakeys or to adress a cell. But you need the actual row. This is done by the following line of code

Dim row As GridViewRow = CType(CType(e.CommandSource, Control).NamingContainer, GridViewRow)

Then get the key or get the cell and cast to a datacontrolfield.

Dim id As Guid = GridView1.DataKeys(row.RowIndex).Value

Dim email As String = CType(row.Cells(2), DataControlFieldCell).Text

Remark: this only works with Boundfields.

[UPDATE:]

This doenst work with final bits. Read http://weblogs.asp.net/hpreishuber/admin/EditPosts.aspx

Leaving EV1Servers

Today Ev1servers have plugged off on of our servers, cause a credit card changed and they cant make their billing within 10 days.

The remember mails were sorted out by spam filtering. For repluging i must pay 25 $

OK: if you dont like me - i change my provider

Goto Hosteurope : its cheaper, have more powerfull servers and 3500 GB Traffic per month.

Posted by preishuber | 1 comment(s)
More Posts