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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Om prakash SinghPosted Jul 9, 2011, 8:42 AM
SqlConnection conn = null;
Shyja AbrahamPosted Jul 9, 2011, 8:11 AM
Om prakash SinghPosted Jul 9, 2011, 2:54 AM
Iterate through all the rows fetch through cmd.execute reader and add the rows in dt12.
"dt12.Rows.Add(dr)"
Shyja AbrahamPosted Jul 8, 2011, 7:28 AM
Om prakash SinghPosted Jul 7, 2011, 7:32 AM
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 AbrahamPosted Jul 6, 2011, 5:36 PM
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 SinghPosted Jul 6, 2011, 8:08 AM
Zoran HorvatPosted Jul 6, 2011, 7:53 AM
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