VB .Net - ASP too

Wednesday, December 21, 2005

Using a control template in datagrid

OK so you want to add a dropdown list to select values for editing data. The first thing you need to do is create the template column. In visual studio you can convert a field to a template while in edit fields mode. once you do this you should have something like the following:

<asp:templatecolumn headertext="columnheader">

<ItemTemplate>
<asp:label id="LabelName" runat="server" Text='<%# Container.dataitem("tempfield") %>'>
</asp>
</ItemTemplate>

<EditItemTemplate>
<asp:dropdownlist id="ddl1" runat="server" datavaluefield="Datavalue" datatextfield="DataDisplay" datasource="sqldatasource" >
</asp:dropdownlist>
</EditItemTemplate>

</asp:TemplateColumn>

the codebehind will look like this wherever you decide to put the code:

'declare variables to hold data
dim templist as DropDownList
dim tempdata as string

'assign the control as the control from the datagrid
templist = e.item.findcontrol("ddl1")
tempdata = templist.SelectedItem.Value

'if using sqldatasource assign the parameter
sqldatasource.updateparameter.item("data").defaultvalue = tempdata

Of course I haven't tested this yet but when I do I will make updates.

For a better understanding read the article by 4guysfromrolla at this link:
http://www.4guysfromrolla.com/webtech/050801-1.2.shtml

Monday, December 05, 2005

Creating a user using the membership.createuser class

Membership.CreateUser Method (System.Web.Security)

SqlProfileProvider Class (System.Web.Profile)

SqlProfileProvider Class (System.Web.Profile)

Read this one first on the profile provider than go back to the last one.

ONDotnet.com: Personalization in ASP.NET

ONDotnet.com: Personalization in ASP.NET


Shows how to use profiles.

Friday, December 02, 2005

Adding an SQL server membership provider

This goes inside configuration. This is a normal connection string nothing out of the ordinary.

<connectionstrings>
<add name="MyLocalSQLServer" connectionString="Initial Catalog=aspnetdb;data source=localhost;Integrated Security=SSPI;" />
</connectionstrings>


This is all within the system.web namespace
Under authentication mode change it to forms and add the forms tag with attributes

<authentication mode="Forms">
<forms
name="SqlAuthCookie"
timeout="10" />
</authentication>
ADd authorization for the site:
<authorization>
<deny users="?" />
<allow users="*" />
</authorization>

Add the provider under authorization tag. Connection string refers to the one added above.

<membership defaultProvider="MySqlMembershipProvider" >
<providers>
<clear/>
<add name="MySqlMembershipProvider"
connectionStringName="MyLocalSQLServer"
applicationName="TestReports"
type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</membership>