Saturday, 1 September 2012

asp.net display code with c# | try-catch-finally in asp.net

asp.net display code with c# | try-catch-finally in asp.net
In this article i have shown to display value in to database using c# using gridview

           try
            {
               con.Open();
               string query = "select * from feesentry_tb";
               SqlCommand cmd = new SqlCommand(query, con);
               SqlDataAdapter da = new SqlDataAdapter(cmd);
               DataTable dt = new DataTable();
               da.Fill(dt);
               grdvw.DataSource = dt;
               grdvw.DataBind();
              
            }
            catch (Exception ex)
            {
                Response.Write(ex);
            }
            finally
            {
                con.Close();
            }
      

Friday, 31 August 2012

Perfect number program source code in vb.net | login

Perfect number program source code in vb.net | login
How to write  Perfect number program code in vb.net using for loop and next
 Dim sum As Integer = 0
        Dim i As Integer
        For i = 1 To Convert.ToInt16(TextBox1.Text) - 1
            If (Convert.ToInt16(TextBox1.Text) Mod i = 0) Then
                sum += i
            End If
        Next
        If sum = Convert.ToInt16(TextBox1.Text) Then
            MsgBox("It is perfect no")
        Else
            MsgBox("It is no perfect no")
        End If

Login form validation in vb.net using username and password field

Login form validation in vb.net using username and password field
Onbutton_click()
{
If (UsernameTextBox.Text = "" And PasswordTextBox.Text = "") Then
            MsgBox("Enter username & password")
        Else

            If (UsernameTextBox.Text = "") Then
                MsgBox("Enter username")
            Else
                If (PasswordTextBox.Text = "") Then
                    MsgBox("Enter password")
                Else
                    If (UsernameTextBox.Text = "scott" And PasswordTextBox.Text = "tiger") Then
                        ProgressBar1.Visible = True
                        ProgressBar1.Value = 0
                        Dim i As Integer = 100000
                        While (i >= ProgressBar1.Value)
                            ProgressBar1.Value = ProgressBar1.Value + 10
                        End While
                        Form1.Show()
                        Me.Hide()

                    Else
                        MsgBox("Enter correct username & password")
                    End If
}

checkbox.checked | listbox.item | radiobutton.cheked in vb.net

checkbox.checked | listbox.item | radiobutton.cheked in vb.net
How to write vb.net code to check check box and select listItem item and add them.
    Private Sub Buttonon_Click() Handles Button1.Click

        listboxvalue.Items.Add("First Name=" + TextBoxvalue1.Text + " Last Name=" + TextBoxvalue2.Text + " Address=" + TextBoxvalue3.Text + " City="
        + ComboBox1.Text + "\nSex=")

        If (radiobuttonvalue.Checked = True) Then
            listboxvalue.Items.Add("Male")
        Else
            listboxvalue.Items.Add("Female")
        End If

        listboxvalue.Items.Add(" Age=" + NumericUpDown1.Value.ToString() + " Hobbies are=")

        If (chkvalue1.Checked = True) Then
            listboxvalue.Items.Add(" Cricket")
        End If

        If (chkvalue2.Checked = True) Then
            listboxvalue.Items.Add(" Football")
        End If

        If (chkvalue3.Checked = True) Then
            listboxvalue.Items.Add(" Tennis")
        End If

        If (chkvalue4.Checked = True) Then
            listboxvalue.Items.Add(" BasketBall")
        End If
    End Sub
End Class

while | if | dropdownlist in javascript

while | if | dropdownlist in javascript
while | if | dropdownlist in javascript
        int i = 0;
        int indx = drpdwn.SelectedIndex;
        int var = 3;
        while (i <= var)
        {
            if (i == indx)
            {
              //  lbl.Text = "you have selected" + indx;
                one.Text =Convert.ToString(indx * 8);
                break;
            }
            else
            {
                i++;
            }
        }

 <table>
    <tr><td>
    <asp:DropDownList ID="drpdwn" runat="server" AutoPostBack="True"
            ontextchanged="drpdwn_TextChanged">
    <asp:ListItem Value="1">Java Programming</asp:ListItem>
    <asp:ListItem Value="2">C Programming</asp:ListItem>
    <asp:ListItem Value="3">Asp Programming</asp:ListItem>
    <asp:ListItem Value="4">c++ Programming</asp:ListItem>
    </asp:DropDownList>
    </td></tr>
    <tr><td>
    <asp:Label runat="server" ID="lbl"></asp:Label>
   
    </td></tr>
    </table>