hello everybody!!!
My Question is like this.
In my .aspx page i have Five texbox ,one Button and one Gridview.
Now after filling these textbox, on button_click event i have to fiill these values of textbox in gridview control WITHOUT using a table..
Is it possible??????????????
if yes then how please tell me.
thanx in advance
Loading
jayant bramhankarPosted Apr 10, 2010, 5:33 AM
I have tried, it fulfill your requirments.
class Data
{
string val1;
string val2;
string val3;
string val4;
string val5;
public string Val1
{
get { return val1; }
set { val1 = value; }
}
public string Val2
{
get { return val2; }
set { val2 = value; }
}
public string Val3
{
get { return val3; }
set { val3 = value; }
}
public string Val4
{
get { return val4; }
set { val4 = value; }
}
public string Val5
{
get { return val5; }
set { val5 = value; }
}
}
//Adding values
private void btnok_Click(object sender, EventArgs e)
{
Data dObj = new Data();
dObj.Val1 = "TextBox1Value";
dObj.Val2 = "TextBox2Value";
dObj.Val3 = "TextBox3Value";
dObj.Val4 = "TextBox4Value";
dObj.Val5 = "TextBox5Value";
ArrayList arr = new ArrayList();
arr.Add(dObj);
dataGridView1.DataSource = arr;
}
//you can add rows explicitly and bound values of Data class.
Hope it helps
kalpesh BhadaniPosted Apr 10, 2010, 6:32 AM
its absolutely corrects and works very fine
kalpesh BhadaniPosted Apr 10, 2010, 2:30 AM
I know this but actually I forgot to say that i wants the values of all these textbox in a single row of gridview..
and also the old row should remain in gridview when I fill all these textbox with another values and again press button..
how to do it??????
please tell me
thanks
jayant bramhankarPosted Apr 9, 2010, 4:49 PM
your solution
on button_Click()
{
ArrayList arr=new ArrayList();
arr.Add("textBox1.text");
arr.Add("textBox2.text");
arr.Add("textBox3.text");
arr.Add("textBox4.text");
arr.Add("textBox5.text");
//Bind to gridview
Gridview1.DataSource=Arr;
Gridview1.DataBind();
}
hope it helps