Hai,
In my form, one textbox and a datagridview,
When we enter the values into the textbox with comas ,the corresponding values displayed into the datagridview from the databse.i want to enter minimum 5 values in to the textbox. plz help?
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Zoran HorvatRank #792 · 2.9K reputationPosted Jul 6, 2011, 3:53 AM EDT
If the question is how to retrieve comma-separated values from the text box, then it would be like this:
string s = "a,b,c,d";
string[] values = s.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
This will create an array containing four distinct strings: "a", "b", "c" and "d".
Zoran
Om prakash Singh126 reputationPosted Jul 6, 2011, 4:08 AM EDT
Shyja Abraham66 reputationPosted Jul 6, 2011, 1:36 PM EDT
DataTable dt21 = new DataTable();
private void textBox6_TextChanged(object sender, EventArgs e)
{
string s = Convert.ToString(textBox6.Text);
string[] values = s.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
int x = values.Length;
for(i=0;i
{
cmd.CommandText = "select doid,doloc,itemcode,itemname,partno,unit,doqty,dorate,dodiscount,dovalue from item i inner join do d on i.itemid=d.itemid where dono='" + values[i] + "'and invoiced='0'";
dr = cmd.ExecuteReader();
dt21.Load(dr);
}
dogiridview.DataSource = dt21;
dr.Close();
}
i use this code ,but it is not work properly
Om prakash Singh126 reputationPosted Jul 7, 2011, 3:32 AM EDT
DataTable dt21 = new DataTable();
private void textBox6_TextChanged(object sender, EventArgs e)
{
dt21=(DataTable)ViewState["Dt"];
string s = Convert.ToString(textBox6.Text);
string[] values = s.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
int x = values.Length;
for(i=0;i
string sql=//your query
dr=cmd.ExecuteReader();
dt21.Rows.Add(dr)
}
ViewState["Dt"]=dt21;
yourGrid.DataSource=dt21
yourGrid.DataBind();
}
Shyja Abraham66 reputationPosted Jul 8, 2011, 3:28 AM EDT
Om prakash Singh126 reputationPosted Jul 8, 2011, 10:54 PM EDT
Iterate through all the rows fetch through cmd.execute reader and add the rows in dt12.
"dt12.Rows.Add(dr)"
Shyja Abraham66 reputationPosted Jul 9, 2011, 4:11 AM EDT
Om prakash Singh126 reputationPosted Jul 9, 2011, 4:42 AM EDT
SqlConnection conn = null;