Here i want to try to read all column value in datagrid using for loop but it not showing any result in the datagrid
please Help me, Thanks in advance
private void CBSalesOrderNo_SelectedIndexChanged(object sender, EventArgs e)
{
string conSTR = "Data Source=" +
(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)) +
"\\freedom.sdf;Persist Security Info=False";
try
{
SqlCeConnection conn = new SqlCeConnection(conSTR);
conn.Open();
string code = "SELECT Shipmentno,Custname,Itemno,Bundleno,Validatedby FROM Items WHERE Salesorder ='" + CBSalesOrderNo.Text + "'";
SqlCeDataAdapter da = new SqlCeDataAdapter(code, conn);
SqlCeCommandBuilder cmd = new SqlCeCommandBuilder(da);
DataSet dset = new DataSet();
da.Fill(dset);
if (CBSalesOrderNo.SelectedIndex > -1)
{
txtShipmentNo.Text = dset.Tables[0].Rows[0]["Shipmentno"].ToString();
txtcustName.Text = dset.Tables[0].Rows[0]["Custname"].ToString();
txtitem.Text = dset.Tables[0].Rows[0]["Itemno"].ToString();
List bundleList = new List();
for (int i = 0; i < bundleList.Count; i++)
{
string data = dset.Tables[i].Rows[i]["Bundleno"].ToString() + dset.Tables[i].Rows[i]["Validatedby"].ToString();
bundleList.Add(new BundleDetails { BundleNo = data });
dataGrid1.DataSource = bundleList;
}
}
}
catch (SystemException se)
{
MessageBox.Show(se.Message);
}
}
public class BundleDetails
{
public string BundleNo { get; set; }
public string Validatedby { get; set; }
}
i try it using sql Editor its working fine in sql Editor...
Shuvojit HalderRank #2,827 · 503 reputationPosted Jun 29, 2015, 8:50 PM EDT
Upendra Pratap ShahiRank #329 · 7.5K reputationPosted Jun 29, 2015, 8:59 PM EDT
Hitendrasing Sisodiya11 reputationPosted Jun 30, 2015, 12:04 AM EDT
Vignesh ManiRank #98 · 22.1K reputationPosted Jun 30, 2015, 12:18 AM EDT
Hitendrasing Sisodiya11 reputationPosted Jul 1, 2015, 1:15 PM EDT
Upendra Pratap ShahiRank #329 · 7.5K reputationPosted Jul 1, 2015, 8:34 PM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts