Results 1 to 6 of 6

Thread: Data Grid [RESOLVED]

  1. #1

    Thread Starter
    Frenzied Member usamaalam's Avatar
    Join Date
    Nov 2002
    Location
    Karachi
    Posts
    1,308

    Data Grid [RESOLVED]

    Hi all,

    I need an editable datagrid with one row only. Means, if user enters one record in the datagrid, I dont want to add a new row in the data grid.

    Thanks.
    Last edited by usamaalam; Dec 29th, 2004 at 04:59 AM. Reason: Resolved

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    There is property for allowing cells editing , I forgot what's called . If you're not so happy with the exist DataGrid , try the ones in CodeProject.com with more functions .

  3. #3

    Thread Starter
    Frenzied Member usamaalam's Avatar
    Join Date
    Nov 2002
    Location
    Karachi
    Posts
    1,308

    Re: Data Grid [RESOLVED]

    Would you please provide me link of that datagrid.
    Last edited by usamaalam; Dec 29th, 2004 at 04:56 AM. Reason: Resolved

  4. #4
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877

    Re: Data Grid

    Quote Originally Posted by usamaalam
    Hi all,

    I need an editable datagrid with one row only. Means, if user enters one record in the datagrid, I dont want to add a new row in the data grid.

    Thanks.
    Do you mean an Unbounded DataGrid or do you mean you want to allow user to add new rows to existing data in the datagrid?

    If its the first case then all you need to do is create a DataTable an empty one and then bind to datasource to that DataTable.
    [VBF RSS Feed]

    There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.

    If I have been helpful, Please Rate my Post. Thanks.

    This post was powered by :

  5. #5

    Thread Starter
    Frenzied Member usamaalam's Avatar
    Join Date
    Nov 2002
    Location
    Karachi
    Posts
    1,308

    Re: Data Grid

    I need an unbound editable datagrid with only one row. Means when user enters record in the first row, I dont want to add second row and restrict datagrid to be only for one record.

  6. #6
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877

    Re: Data Grid

    Quote Originally Posted by usamaalam
    I need an unbound editable datagrid with only one row. Means when user enters record in the first row, I dont want to add second row and restrict datagrid to be only for one record.
    Here is an example, i have added an empty row and then disabled AllowNew property. You could also check the RowChanged event and disable it there if you need to allow n number of rows in future instead of one.

    Here is the code :

    Code:
     
    private void Form1_Load(object sender, System.EventArgs e)
    		{
    			DataTable dt = new DataTable();
    		
    			dt.Columns.Add("Children Name", Type.GetType("System.String"));
    			dt.Columns.Add("Age", Type.GetType("System.Int32"));
    			dt.Columns.Add("Sex", Type.GetType("System.String"));
    
    			object [] d = {"",0,""};
    
    						
    			dt.Rows.Add(d);
    			
    			this.dataGrid1.DataSource = dt.DefaultView;
    			((DataView)this.dataGrid1.DataSource).AllowNew=false;
                			
    			//dt.RowChanged+=new DataRowChangeEventHandler(dt_RowChanged);
    
    		}
    [VBF RSS Feed]

    There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.

    If I have been helpful, Please Rate my Post. Thanks.

    This post was powered by :

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width