.NET Diary

October 28, 2009

DropDown List With HardCoded Values with Default Selected a value

Filed under: All, ASP.NET, C# — leoullas @ 10:41 am

There are two ways:

 

Way 1:

In aspx file:

     <td style=”width: 90px; height: 56px;” valign=”middle”>

        <asp:DropDownList ID=”ddlTime” runat=”server” Width=”131px” onchange=”clickClient();”  Height=”19px”>

</asp:DropDownList>

     </td>

In aspx.CS file:

    public static void PopulateDdlTime(DropDownList ddlTime)

    {

        ddlTime.Items.Add(new ListItem(“12:00AM–08:00AM”, “1200AM0800AM”));

        ddlTime.Items.Add(new ListItem(“08:00AM–04:00PM”, “0800AM0400PM”));

        ddlTime.Items.Add(new ListItem(DRISInternatiolization.DRISInternatiolization.GetLabelText(“464”), “Customize”));

        ddlTime.SelectedValue = “0800AM0400PM”;

    }

protected void Page_Load(object sender, EventArgs e)

       {

PopulateDdlTime(ddlTime);

……

……

}

Way 2:

In aspx file:

<td style=”width: 90px; height: 56px;” valign=”middle”>

    <asp:DropDownList ID=”ddlTime” runat=”server” Width=”131px” onchange=”clickClient();” Height=”19px”>

                  <asp:ListItem Value=”1200AM0800AM”>12:00AM–08:00AM</asp:ListItem>

                  <asp:ListItem Value=”0800AM0400PM” Selected=”True”>08:00AM–04:00PM</asp:ListItem>

                  <asp:ListItem Value=”Customize”>Customize…</asp:ListItem>

    </asp:DropDownList>

</td>

Advertisements

Problem: Cant delete after copying FileInfo “The process cannot access the file because it is being used by another process.”

Filed under: All, ASP.NET, C# — leoullas @ 10:34 am

Solution:

You might have not disposed while reading/writing.
Use either of these two:

1.

StreamWriter objStreamWriterUp = null;

TextReader objTextReaderUp = null;

try

{

using (objTextReaderUp = new StreamReader(sourceFilePath)) 

{

using (objStreamWriterUp

= new StreamWriter(destiFilePath, !blIsFirstTimeCl))

{

//your code

}

}

}

catch (Exception ex)

{

throw;

}

finally

{

 

if (objStreamWriterUp != null)

{

                    objStreamWriterUp.Dispose();

}

       }

2.

StreamWriter objStreamWriterUp = null;

TextReader objTextReaderUp = null;

try

{

objTextReaderUp = new StreamReader(sourceFilePath);

objStreamWriterUp = new StreamWriter(destiFilePath, !blIsFirstTimeCl);

//your code

}

catch (Exception ex)

{

throw;

}

finally

{

 

if (objTextReaderUp != null)

{

objTextReaderUp.Dispose();

}

 

if (objStreamWriterUp != null)

{

objStreamWriterUp.Dispose();

}

       }

  

 

ACID

Filed under: All, SQL — leoullas @ 10:10 am

ACID (an acronymn for Atomicity Consistency Isolation Durability) is a concept that Database Professionals generally look for when evaluating databases and application architectures. For a reliable database all this four attributes should be achieved.

  • Atomicity states that database modifications must follow an “all or nothing” rule. Each transaction is said to be “atomic.” If one part of the transaction fails, the entire transaction fails. It is critical that the database management system maintain the atomic nature of transactions in spite of any DBMS, operating system or hardware failure.
  • Consistency states that only valid data will be written to the database. If, for some reason, a transaction is executed that violates the database’s consistency rules, the entire transaction will be rolled back and the database will be restored to a state consistent with those rules. On the other hand, if a transaction successfully executes, it will take the database from one state that is consistent with the rules to another state that is also consistent with the rules.
  • Isolation requires that multiple transactions occurring at the same time not impact each other’s execution. For example, if Joe issues a transaction against a database at the same time that Mary issues a different transaction, both transactions should operate on the database in an isolated manner. The database should either perform Joe’s entire transaction before executing Mary’s or vice-versa. This prevents Joe’s transaction from reading intermediate data produced as a side effect of part of Mary’s transaction that will not eventually be committed to the database. Note that the isolation property does not ensure which transaction will execute first, merely that they will not interfere with each other.
  • Durability ensures that any transaction committed to the database will not be lost. Durability is ensured through the use of database backups and transaction logs that facilitate the restoration of committed transactions in spite of any subsequent software or hardware failures.

Blog at WordPress.com.

%d bloggers like this: