I'm facing an issue with databinding RadGrid to an ObjectDataSource, which admittedly I'm rather new at.
Users fill out a simple form and then click a button. This button should create a new object, and add it to a stongly-typed collection (list) of objects.
I was supposing that after the call to Databind, the RadGrid should update with the current customer record, but it doesn't. "No Records to Display" remains there perpetual. (I am using RadAjaxManager, so that the button updates the radgrid)
So what am I missing? The Add method does work. but the objectdatasource doesn't seem to be doing the job.
Someone please point out my begginer's mistake and put me out of my misery. Thanks in advance.
Users fill out a simple form and then click a button. This button should create a new object, and add it to a stongly-typed collection (list) of objects.
protected void btnAddCustomer_Click(object sender, EventArgs e) |
{ |
Customers custs = (Customers)Session["Customers"]; |
Customer cust = new Customer(); |
cust.CustomerID = this.cbCustomerList.SelectedValue; |
custs.Add(cust); |
Session["Customers"] = custs; |
this.rgCustomers.Databind(); |
} |
I was supposing that after the call to Databind, the RadGrid should update with the current customer record, but it doesn't. "No Records to Display" remains there perpetual. (I am using RadAjaxManager, so that the button updates the radgrid)
So what am I missing? The Add method does work. but the objectdatasource doesn't seem to be doing the job.
<asp:ObjectDataSource ID="odsCustomers" runat="server" |
DataObjectTypeName="EClassLibrary.Customer" InsertMethod="Add" |
SelectMethod="Select" TypeName="EClassLibrary.Customers"> |
</asp:ObjectDataSource> |
public DataTable Select() |
{ |
DataTable myTable = new EDataSet.dtCustomersDataTable(); |
EDataSet.dtCustomersRow myRow = (EDataSet.dtCustomersRow) myTable.NewRow(); |
foreach (Customer cust in this) |
{ |
myRow.CustomerName = prov.GetCustomerName(); |
myRow.Company = prov.GetCustomerCompany(); |
myRow.JobTitle = prov.GetCustomerJobTitle(); |
myRow.UserID = prov.GetProviderUserID(); |
myTable.Rows.Add(myRow); |
} |
return myTable; |
} |
Someone please point out my begginer's mistake and put me out of my misery. Thanks in advance.