473,385 Members | 1,602 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Master-Detail datagrid[allownew = false]

In my one datagrid, there is master - detail relationship.
I can set dv.allownew = false, However, as the user click into detail, it
can't set to allownew = false.
Does anyone know how to solve it ?
Nov 21 '05 #1
1 1387
[I found the solution from other newsgroup]
I think you can subscribe to the DataGrid's Navigate event, get the
CurrencyManager there, and set the AllowNew property of the
CurrencyManager's List at that point. Below is some code.
=============
Clay Burch, .NET MVP

Visit www.syncfusion.com for the coolest tools

private void Form1_Load(object sender, System.EventArgs e)
{
DataTable parentTable = GetParentTable();
DataTable childTable = GetChildTable();
DataSet ds = new DataSet();
ds.Tables.AddRange(new DataTable[]{parentTable, childTable});

DataRelation parentToChild = new DataRelation("ParentToChild",
parentTable.Columns["parentID"], childTable.Columns["ParentID"]);

ds.Relations.AddRange(new DataRelation[]{parentToChild});

this.dataGrid1.DataSource = parentTable.DefaultView;
parentTable.DefaultView.AllowNew = false;

this.dataGrid1.Navigate += new
NavigateEventHandler(dataGrid1_Navigate);
}

private void dataGrid1_Navigate(object sender, NavigateEventArgs e)
{
if(e.Forward)
{
CurrencyManager cm =
(CurrencyManager)this.dataGrid1.BindingContext[this.dataGrid1.DataSource,
this.dataGrid1.DataMember];
((DataView)cm.List).AllowNew = false;
}
}
----------------------------------------
"Agnes" <ag***@dynamictech.com.hk> ¦b¶l¥ó
news:%2***************@tk2msftngp13.phx.gbl ¤¤¼¶¼g...
In my one datagrid, there is master - detail relationship.
I can set dv.allownew = false, However, as the user click into detail, it
can't set to allownew = false.
Does anyone know how to solve it ?

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: damiensawyer | last post by:
Hello all, I'm very new to all of this. I have a theme and a skin (the standard ones). I have a standard master page which is holding a custom ascx which has a treeview in it. Can someone...
2
by: Scott | last post by:
I'm using a master page (mp_TableMaint.aspx) with one Content area (ID: Content1). Content1 contains several usercontrols, which are hidden. The goal is to show the correct control based on the...
4
by: Learner | last post by:
Hello, Here is a little bit of what I am working ... I have selected Header and Side lay out for my Master Page. All my links go on the Side and the content on to the right pane. I have no...
4
by: Greg | last post by:
I'm guessing the problem I'm having has something to do with Master Pages or DetailsView because the exact same code works fine on a page without a Master Page and DetailsView controls. The...
5
by: André | last post by:
Hi, I am using this code to prevent multi click asp.net 2.0 c#, System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("SetValue();"); sb.Append("if...
17
by: Rob R. Ainscough | last post by:
Again another simple concept that appears NOT to be intuitive or I'm just stupid. I've read the WROX book and the example doesn't actually show how the .master page links in the other content...
4
by: Diane Yocom | last post by:
I'm trying to use an Atlas UpdatePanel to just update a label when a text box has changed. The problem is that my textbox is in a user control and I'm using Master Pages - with the combination of...
0
by: danielclark | last post by:
Hello, Here's my scenario: I have a simple contact form set up where the user can choose how they wish to be contacted from a list of options presented in a Select box (DropDownList)....
4
by: evantay | last post by:
I'm using ASP.NET 2.0 with VS.NET 2005. I'm trying to access properties from my master pages within a page that inherits from that master page (a child page). However the values are always null....
6
by: =?Utf-8?B?SmF5IFBvbmR5?= | last post by:
I am trying to access a Public property on a Master Page from a Base Page. On the content pages I have the MasterType Directive set up as follows: <%@ MasterType virtualpath="~/Master.master" %>...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.