h1.post-title { color:orange; font-family:verdana,Arial; font-weight:bold; padding-bottom:5px; text-shadow:#64665b 0px 1px 1px; font-size:32px; } -->

Pages

Add DataGridView Column Value in C#.net

Today, we will discuss about Add DataGridView Column Value in C#.net
private double  ADDCoulmnValue(int ColIdx, DataGridView dgv)
        {
            double d = 0;
            for (int idx = 0;idx <dgv.Rows.Count;idx++)
            {
                tot += Convert.ToDouble(dgv.Rows[idx].Cells[ColIdx].Value);
            }
            return tot;
        }

Add DataGridView Column Value in VB.Net

Today,We will see "How to Add DataGridView Column Value in VB.NET?"
Private Function ADDCoulmnValue(ColIdx As Integer, dgv As DataGridView) As Double Dim d As Double = 0 For idx As Integer = 0 To dgv.Rows.Count - 1 tot += Convert.ToDouble(dgv.Rows(idx).Cells(ColIdx).Value) Next Return tot End Function

Fetch Text File data into Datagridview in VB.Net

Today we will see Fetch Text file Data into Datagridview in VB.net
Text file Data Format
111;222
333;444
555;666
777;888
Code:
private Sub DispaydatafromTextFile(txtFilePath As String) '1st you must create columns to dgv, like: dataGridView1.Columns.Add("col1", "Column1") dataGridView1.Columns.Add("col2", "Column2") 'and so on... Using sr As New StreamReader(txtFilePath) Dim row As Integer = 0 Dim line As String While (InlineAssignHelper(line, sr.ReadLine())) IsNot Nothing Dim columns As String() = line.Split(";"C) dataGridView1.Rows.Add() For i As Integer = 0 To columns.Length - 1 dataGridView1(i, row).Value = columns(i) Next row += 1 End While End Using End Sub
Private Sub button1_Click(sender As Object, e As EventArgs) DispaydatafromTextFile("C:\Test.txt") textBox1.Text = Convert.ToString(dataGridView1.CurrentRow.Cells(0).Value) textBox2.Text = Convert.ToString(dataGridView1.CurrentRow.Cells(1).Value) End Sub
Private Sub dataGridView1_CellClick(sender As Object, e As DataGridViewCellEventArgs) textBox1.Text = Convert.ToString(dataGridView1.Rows(e.RowIndex).Cells(0).Value) textBox2.Text = Convert.ToString(dataGridView1.Rows(e.RowIndex).Cells(1).Value) End Sub

Fetch Text File Data into Datagridview in C#.Net

Today ,we will discuss about how to fetch data from Text File into Datagridview in C#.net
Text File Data Format
111;222
333;444
555;666
777;888
Code 
private void DispaydatafromTextFile(string txtFilePath)
 {
 //1st you must create columns to dgv, like:
 dataGridView1.Columns.Add("col1", "Column1");
 dataGridView1.Columns.Add("col2", "Column2");
 //and so on...
 using (StreamReader sr = new StreamReader(txtFilePath))
 {
 int row = 0;
 string line;
 while ((line = sr.ReadLine()) != null)
 {
 string[] columns = line.Split(';');
 dataGridView1.Rows.Add();
 for (int i = 0; i < columns.Length; i++)
 {
 dataGridView1[i, row].Value = columns[i];
 }
 row++;
 }
 }
 }
 private void button1_Click(object sender, EventArgs e)
 {
 DispaydatafromTextFile(@"C:\Test.txt");
 textBox1.Text = Convert.ToString(dataGridView1.CurrentRow.Cells[0].Value);
 textBox2.Text = Convert.ToString(dataGridView1.CurrentRow.Cells[1].Value);
 }
 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
 {
 textBox1.Text = Convert.ToString(dataGridView1.Rows[e.RowIndex].Cells[0].Value);
 textBox2.Text = Convert.ToString(dataGridView1.Rows[e.RowIndex].Cells[1].Value);
 }

Find existing Item in ComboBox in C#.net

Today we will see "Find Existing Item in ComboBox in C#.net"

Code
private void ComboBox1_Leave(System.Object sender, System.EventArgs e)
{
int resultIndex = -1;
resultIndex = ComboBox1.FindStringExact(ComboBox1.Text);
if (resultIndex > -1) {
MessageBox.Show("Found It");
}
else
{
MessageBox.Show("Did Not Find It");
}
}

Find existing item in ComboBox in Vb.net

Today we will discuss about Find existing item in Combobox in VB.Net

Private Sub ComboBox1_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.Leave
Dim resultIndex As Integer = -1
resultIndex = ComboBox1.FindStringExact(ComboBox1.Text)
If resultIndex > -1 Then
MessageBox.Show("Found It")
Else
MessageBox.Show("Did Not Find It")
End If
End Sub

Define ViewBag in MVC

Define ViewBag in MVC
ViewBag is used to pass data from a controller to the view.ViewBag object holds the data.

Define Helper Classes

Define Helper Classes
There are several Helper classes in MVC frame work. 
1.Form Helper- Radio buttons, textboxes,list boxes etc.
2.URL helpers
3.HTML helpers- Encode, Decode, AttributeEncode, and RenderPartial.

Define Non-Action Methods

Define Non-Action Methods

  • All action methods in a Controller are defined as public method.
  •  If you want some method as non action method,mark the method with NonAction Attribute.

Define Action Methods Parameters

Define Action Methods Parameters

  • Request and Response methods can be called from the action method of the controller.
  • If the parameter to an action method is passing through the URL, there are several ways to access it into our action method.