TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
ullas K
NA
55
0
Changing the Column value of a bound datagridview
Feb 9 2013 7:12 AM
Hi,
I have a datagridview with columns
Member No, Member Name ,Address,Phone and Membership_Status
.
membership_Status
column is of type
integer
(Column values will be
1,2,3,4
).What i need is when the datagridview is
populated i should replace the integer values in column membership_Status
,ie if
value is "1"
then the column should show
"Guardian"
.If "2" the Status column should show "Life" and so on. but i am getting error;
System.Exception:Guardian is not a valid value for int32---->System.FormatException:Input string was not in a correct format
How can i correct this formatexception.My code is shown below;
LibraryLib.Library obj = new LibraryLib.Library();
DataTable dt;
DataGridViewRow dgr;
int i ;
dt = obj.select("select member_no,mname,address,phone,membership_status from Member_master");
dataGridView1.DataSource = dt;
dataGridView1.Refresh();
int status;
for (i = 0; i < dataGridView1.Rows.Count; i++)
{
dgr = dataGridView1.Rows[i];
status = int.Parse(dgr.Cells[4].Value.ToString());
switch (status)
{
case 1:
dgr.Cells[4].Value = "Guardian";
break;
case 2:
dgr.Cells[4].Value = "Life";
break;
case 3:
dgr.Cells[4].Value = "Active";
break;
}
How can i acheive this.Pls give me the code to do this
Thanks in advance
Reply
Answers (
4
)
teleprompter application in vb.net
Filter Combo box or make combo box searchable