C# winforms Application

Posted by Pruthvi123 under C# on 8/17/2013 | Points: 10 | Views : 1120 | Status : [Member] | Replies : 1
Hi,

In c# winform i have two cardviews.first cardview contains category items.second cardview should display respective category details once i click on first cardview category.can anyone help me how to achieve this scenario.

suppose in first cardview i have puff as a category.when i click on that puff category its respective items like different puffs should display in second cardview like its price..etc.

Pruthvi


Responses

Posted by: Satyapriyanayak on: 8/18/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
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 Datagridview
{
public partial class Form1 : Form
{
SqlConnection con = new SqlConnection(@"server = HOME-SAT/SQLEXPRESS;data source = .; initial catalog = test; user id=sa;pwd =pintu ;integrated security = SSPI");
SqlCommand com;
SqlDataAdapter sqlda;
DataSet ds;
string str;

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
con.Open();
str = "select ProductName from product";
com = new SqlCommand(str, con);
ds = new DataSet();
sqlda = new SqlDataAdapter(com);
sqlda.Fill(ds, "product");
con.Close();
dataGridView1.DataSource = ds;
dataGridView1.DataMember = "product";
}

private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
con.Open();
str = "select * from product where ProductName='" + dataGridView1.CurrentRow.Cells[0].Value.ToString() + "'";
com = new SqlCommand(str, con);
sqlda = new SqlDataAdapter(com);
ds = new DataSet();
sqlda.Fill(ds, "product");
dataGridView2.DataMember = "product";
dataGridView2.DataSource = ds;
con.Close();
}
}
}


If this post helps you mark it as answer
Thanks

Pruthvi123, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response