Hi ,
I havent seen any example for Runtime databinding with Relationship based DataSet.I wanna do this scenario in my site.
I have got Access Database.There is two table with relationship many to one named Products and Categories.So i wanna show my Foreign table's data in a ComboBox include in WebdataGrid.And for CRUD operations i wanna do this manually like getting values from rows and send this values to database. And if ya write me an example for this i will be happy.
So here is my codes;
protected void Page_Load(object sender, EventArgs e)
{
string conStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=";
conStr += Server.MapPath("~/App_Data/demo.mdb");
dbCon = new System.Data.OleDb.OleDbConnection(conStr);
dbCon.Open();
if (!Page.IsPostBack)
buildGrid();
}
private void buildGrid()
string sql;
sql = "SELECT * FROM Products";
System.Data.OleDb.OleDbDataAdapter daSrc = new System.Data.OleDb.OleDbDataAdapter(sql, dbCon);
DataTable oTable1 = new DataTable("Products");
daSrc.Fill(oTable1);
sql = "SELECT * FROM Categories";
daSrc = new System.Data.OleDb.OleDbDataAdapter(sql, dbCon);
DataTable oTable2 = new DataTable("Categories");
daSrc.Fill(oTable2);
DataSet dsSrc = new DataSet();
dsSrc.Tables.Add(oTable1);
dsSrc.Tables.Add(oTable2);
dsSrc.Relations.Add(dsSrc.Tables["Categories"].Columns["CategoryId"], dsSrc.Tables["Products"].Columns["CategoryId"]);
WebDataGrid1.DataSource = dsSrc;
Hello,
If you want to represent relational data structure you should use WebHierarchicalDataGrid not WebDataGrid component. I would suggest take a look at the following sources:
Live samples : https://www.infragistics.com/samples/aspnet/hierarchical-data-grid/overview
Video presentation WHDG : https://www.youtube.com/playlist?list=PLDAFFE8C757FED32E
Hope this helps.