Solved

VB.Net DataGrid - Row Add coding questions

Posted on 2007-03-29
1
340 Views
Last Modified: 2010-04-23
Hello,
 
I'm looking for a way to smarten up my DataGrid in VB.Net 2005.
 
On the initial load of data into my DataGrid, I set columns 0 and 1 to ReadOnly, but for a RowEnter event I plan to change the ReadOnlly of Column(0) to False and then back to True again on RowLeaving Event.

This DataGrid has a DataSource of a DataTable in VB.  

What I'd like to do is default zero's in all DataGrid columns from index 2-14 so they don't leave these as null values in a DataTable\Column that does not allow null.

Can I set DataGrid cells to a value or do I need to create this row in my DataTable source and then refresh my DataGrid?

Thanks!
JMO9966
0
Comment
Question by:JMO9966
1 Comment
 
LVL 34

Accepted Solution

by:
Sancler earned 250 total points
ID: 18817854
You can set this in your datatable.  Try this

        For i As Integer = 2 To 14
            <myDataTable>.Columns(i).DefaultValue = 0
        Next

Then, when a user goes into edit the new row in the datagrid, all the columns from 2 to 14 will have 0s in them.

Roger
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now