when i enter employee_id nd press SHOW button then
show griedview data for perticular employee_id data
Using visual studio 2008 c#.net with sql server 2005
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Khan Abrar AhmedPosted Apr 6, 2014, 8:36 AM
SelectCommand="SELECT [FirstName], [SecondName], [ThirdName], [EmployeeID] FROM [Users] WHERE ([EmployeeID] = @EmployeeID)"
>
in .cs file
protected void btnShow_Click(object sender, EventArgs e)
{
ParameterCollection prm = SqlDataSource1.SelectParameters;
prm[0].DefaultValue = txtEmpID.Text;
}
Khan Abrar AhmedPosted Apr 8, 2014, 1:36 AM
Can you please send the aspx and aspx.cs code so I can look on it.
pankaj diyoraPosted Apr 7, 2014, 2:59 PM
Update Employess Details
Munesh SharmaPosted Apr 6, 2014, 9:04 AM
Click on drop down list in write this code
{
string str = "server = MUNESH\\SQL2008R2;Database=datastore;UID=sa;Password=123;";
SqlConnection con = new SqlConnection(str);
string query = "select * from tablename where name = '"+dropdownlist.text+"' ";
SqlCommand cmd = new SqlCommand( query,con);
sqldatareader dbr;
try
{
con.open();
dbr = cmd.executereader();
while(dbr.read())
{
string sID = (string) dbr["ID"].tostring;
string sname = (string) dbr["name"] // name is string value
string sage = (string) dbr["age"].tostring;
textbox1.text = sid;
textbox2.text = sname;
textbox3.text = sage;
showgrid();
}
catch(execption es)
{
messagebox.show(es.message);
}
}
}If you want to more operation with grid view or data gridview then go to my C-sharp corner blogs.
pankaj diyoraPosted Apr 6, 2014, 8:11 AM
Khan Abrar AhmedPosted Apr 6, 2014, 7:05 AM
public Datatable bindGridview(int empID)
{
//Call the store procedure or sql query to get the data from database
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count == 0)
{
GridView1.Visible = false;
}
else
{
GridView1.Visible = true;
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
bindGridview(empID)
}
Hope this will help.