TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Asif Hasan
NA
2
2k
C# data search in database using gridview
Dec 25 2014 1:59 AM
I am using service-based Database and entity model for creating and recording data.I am able to record and view the data in gridview. But I need to search the data In the gridview. How I can I do this Plz help.
(suppose I record 3 data..the names are A,B,C...when I write in the textbox is A then I need to show the full data of A, that means only the table row of A....(means the name,bloodgroup,address and cellno of A)
form 1 code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace BloddBankManagement
{
public partial class BloodBankForm : Form
{
public BloodBankForm()
{
InitializeComponent();
}
private void Btnregister_click(object sender, EventArgs e)
{
RegisterUser user = new RegisterUser();
user.Show();
}
private void buttonview_Click(object sender, EventArgs e)
{
ViewRecords record = new ViewRecords();
record.Show();
}
}
}
RegisterUser code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace BloddBankManagement
{
public partial class RegisterUser : Form
{
private Database1Entities2 bloodbank= new Database1Entities2();
public RegisterUser()
{
InitializeComponent();
}
private void button1click_register(object sender, EventArgs e)
{
BloodBankM bank = new BloodBankM();
String name1 = textBox1.Text;
String bldgrp=textBox2.Text;
String address = textBox3.Text;
String cellno = textBox4.Text;
bank.Name = name;
bank.Bloodgroup = after;
bank.Address = address;
bank.Cellno = cellno;
bloodbank.AddToBloodBankMs(bank);
bloodbank.SaveChanges();
MessageBox.Show("Record Saved");
}
}
}
ViewRecordscode:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.Objects;
using System.Data.SqlClient;
namespace BloddBankManagement
{
public partial class ViewRecords : Form
{
private Database1Entities2 bloodbank = new Database1Entities2();
public ViewRecords()
{
InitializeComponent();
dataGridView1.DataSource = bloodbank.BloodBankMs;
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
//I need the data search code here
}
}
}
Reply
Answers (
1
)
What is the different?
How to exchange the child's of a tree in c++?