private void button1_Click(object sender, EventArgs e) { using (cmd = new SqlCommand("sp_mstRole", con)) { if (con.State == ConnectionState.Closed) con.Open(); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@RoleName", ""); cmd.Parameters.AddWithValue("@SiteCode", "Head"); cmd.Parameters.AddWithValue("@Mode", "F"); cmd.Parameters.AddWithValue("@id", ""); ds = new DataSet(); da = new SqlDataAdapter(cmd); ds.Clear(); da.Fill(ds); if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Columns.Count; i++) listView1.Columns.Add(ds.Tables[0].Columns[i].ColumnName.ToString(), listView1.Width / 6 - 1); } listView1.Columns.Add("Control", listView1.Width / 6 - 1); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { ListViewItem row = new ListViewItem(ds.Tables[0].Rows[i][0].ToString()); for (int j = 1; j < ds.Tables[0].Columns.Count; j++) { row.SubItems.Add(ds.Tables[0].Rows[i][j].ToString()); } row.SubItems.Add("controls"); listView1.Items.Add(row); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)