Select Values from a dataset into anothr dataset
Revision 1
Hi all,
I have a dataset which binds data to the Gridview in my page. I have check boxes to it. Whe i click a button in my page i need to bind the selected rows in my gridview into another dataset or into another datatable.pls help how to do it.. i have attached my code with this...
pls help with necessary changes in my code...
public void fillgrid()
{
string connString = "Data Source=shipchn111\\sqlexpress;Initial Catalog=ISSUsers;User=sa;Password=Password1;Integrated Security=false";
string sqlQuery = "SELECT Employee_ID,Employee_Name,Employee_Country,Age,Contact_Number,Employee_Mail,DateOfJoining,Department_ID,Manager,Salary FROM ISSEmployees ORDER BY Employee_Country";
getResultSet(connString, sqlQuery);
gridISSControl.DataSource = dsResultTable;
gridISSControl.DataBind();
}
public DataSet getResultSet(string connectionString, string sqlSentence)
{
try
{
string connString = connectionString;
string sqlQuery = sqlSentence;
dsResultTable = new DataSet();
dt = new DataTable();
SqlCommand SqlCmdObject = new SqlCommand(sqlQuery, SqlConObject);
SqlDataAdapter da = new SqlDataAdapter(SqlCmdObject);
da.Fill(dsResultTable);
}
catch (Exception e)
{
lblError.Text = e.Message;
}
finally
{
SqlConObject.Close();
}
return dsResultTable;
}
public void CreateDatatableofSelectedRows()
{
ArrayList names = new ArrayList();
foreach (GridViewRow gvr in this.gridISSControl.Rows)
{
if (((System.Web.UI.WebControls.CheckBox)gvr.FindControl("chkSelect")).Checked == true)
{
names.Add(gvr.Cells[1].Text);
}
}
this.lblError.Text = string.Empty;
foreach (object itm in names)
{
}
}
Posted 5-Oct-12 0:42am
by
ajithk444.