Thursday, April 28, 2005

Showing Checkboxes in Grid

This is a DataGrid uses a template column to show a bit field in a checkbox. In ASP.Net you can achieve this without much programming effort.

This page uses the method GetData() to retrieve data from the Authors database


The Script...

System.Data.DataSet GetData()
{
string connectionString = "server=\'(local)\'; user id=\'sa\';password=\'pwd\'; database=\'pubs\'";
System.Data.SqlClient.SqlConnection dbConnection = new System.Data.SqlClient.SqlConnection(connectionString);

string Sql = "SELECT au_id, au_lname, contract FROM authors";
System.Data.SqlClient.SqlCommand dbCommand = new System.Data.SqlClient.SqlCommand();
dbCommand.CommandText = Sql;
dbCommand.Connection = dbConnection;

System.Data.SqlClient.SqlDataAdapter dataAdapter = new System.Data.SqlClient.SqlDataAdapter();
dataAdapter.SelectCommand = dbCommand;
System.Data.DataSet dataSet = new System.Data.DataSet();
dataAdapter.Fill(dataSet);

return dataSet;
}

void Page_Load(object sender, EventArgs e)
{
DataGrid1.DataSource = GetData();
DataGrid1.DataBind();
}




<html>
<head>
</head>
<body>
<form runat="server">
<asp:DataGrid id="DataGrid1" runat="server" AutoGenerateColumns="False"
BorderStyle="Double" GridLines="Horizontal" BorderWidth="3px" BorderColor="#336666" BackColor="White" CellPadding="4" Width="75%">
<HeaderStyle font-bold="True" forecolor="White" backcolor="#336666"></HeaderStyle>
<ItemStyle forecolor="#333333" backcolor="White"></ItemStyle>
<Columns>
<asp:BoundColumn DataField="au_id" HeaderText="au_id"></asp:BoundColumn>
<asp:BoundColumn DataField="au_lname" HeaderText="au_lname"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="contract">
<ItemStyle horizontalalign="Center"></ItemStyle>
<ItemTemplate>
<asp:CheckBox id="CheckBox1" runat="server" Checked='<%# DataBinder.Eval(Container.DataItem, "contract") %>'></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</form>
</body>
</html>

Monday, April 25, 2005

Unable to start debugging on the web server.

Click Start, point to Programs, point to Administrative Tools, and then click Domain Controller Security Policy.

Click Security Settings.

Click Local Policies, and then click User Rights Assignment.
In the right pane, double-click Impersonate a client after authentication.

In the Security Policy Setting window, click Define these policy settings.
Click Add, and then click Browse.

In the Select Users or Groups window, select the IWAM account name, click Add, and then click OK.
Click OK two times.

To enforce an update of the computer policy, type the following command at a command prompt, and then press ENTER:
secedit /refreshpolicy machine_policy /enforce

At the command prompt,
type iisreset, and then press ENTER.