windows form Data Repeater

Posted by vinaykannegundla-20815 under Visual Studio on 3/25/2013 | Points: 10 | Views : 9673 | Status : [Member] | Replies : 4
I am Desgining DataRepeater control in Windows form application and datarepeaterItem adda the one TextBox. now i execute the form it shows the blank form . I Need without using DataSource to show the TextBox in dataRepeater in run Time.




Responses

Posted by: Karthikreddy on: 3/26/2013 [Member] Starter | Points: 25

Up
0
Down
private void DataRepeaterForm_Load(object sender, EventArgs e)

{
SqlConnection con = new SqlConnection("Data Source=ADRIAN-PC; Initial Catalog=AdventureWorks2008R2; Integrated Security=true;User id=;password=");

SqlCommand cmd = new SqlCommand("Select * from Person.Person", con);
SqlDataAdapter adapt = new SqlDataAdapter(cmd);

DataTable items = new DataTable();
adapt.Fill(items);

textBox1.DataBindings.Add("Text", items, "FirstName");
label1.DataBindings.Add("Text", items, "LastName");

TextBox myUcTextBox1 = (TextBox)myUC1.Controls.Find("textBox1", true).First();

if( myUcTextBox1 != null)
myUcTextBox1.DataBindings.Add("Text", items, "LastName");

dataRepeater1.DataSource = items;
}


k@rth!k
karthikreddy08a50@gmail.com

vinaykannegundla-20815, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikreddy on: 3/26/2013 [Member] Starter | Points: 25

Up
0
Down
BindingSource bindingSource1 = new BindingSource();

bindingSource1.DataSource = items;
textBox1.DataBindings.Add("Text", bindingSource1, "FirstName");
label1.DataBindings.Add("Text", bindingSource1, "LastName");
dataRepeater1.DataSource = bindingSource1;


k@rth!k
karthikreddy08a50@gmail.com

vinaykannegundla-20815, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikreddy on: 3/26/2013 [Member] Starter | Points: 25

Up
0
Down
private void Form1_Load(object sender, EventArgs e) 

{
bindingsource = new BindingSource();
ds = new DataSet("Preferences");

DataTable table = new DataTable("Preference");

table.Columns.Add("Value");

table.Columns.Add("OverflowBehaviour");

for (int i = 1; i <= 8; i++)
{
if (i < 5)
table.Rows.Add(i, ValueTypeAutoIncrementOverflowBehaviour.Exception);
else
table.Rows.Add(i, ValueTypeAutoIncrementOverflowBehaviour.Wrap);
}

ds.Tables.Add(table);

bindingsource.DataSource = ds;
bindingsource.DataMember = "Preference";

textBox1.DataBindings.Add(new Binding("Text", bindingsource, "Value", true, DataSourceUpdateMode.OnValidation));

comboBox1.DataBindings.Add("SelectedItem", bindingsource, "OverflowBehaviour", false, DataSourceUpdateMode.OnValidation);

dataRepeater.DataSource = bindingsource;
}


k@rth!k
karthikreddy08a50@gmail.com

vinaykannegundla-20815, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: vinaykannegundla-20815 on: 3/26/2013 [Member] Starter | Points: 25

Up
0
Down
ya karthik thats correct, With out Data Source we Can't execute Data Repeater

vinaykannegundla-20815, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response