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
fateme soleimani
NA
2
4.4k
please helpppp how to add record to database with gridjanus
Oct 6 2014 1:39 PM
hi every one
i want add a one record to sql from grid janus and one cell from a editbox control
with binding navigator but can not add and message show column code can not null.
my source code:
<pre lang="cs">private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
{
codemax = Convert.ToInt32(fatemeTableAdapter.maxcode());
codemax = codemax + 1;
editBox1.Text = codemax.ToString();
((DataRowView)fatemeBindingSource1.Current).Row["code"] = codemax;
}</pre>
and savebinding:
<pre lang="cs">private void save_Click(object sender, EventArgs e)
{
int g, b;
g=Convert.ToInt32(gridEX1.CurrentRow.Cells["code_b"].Value);
b=Convert.ToInt32(gridEX1.CurrentRow.Cells["name"].Value) ;
((DataRowView)fatemeBindingSource1.Current).Row["code_b"] = g;
((DataRowView)fatemeBindingSource1.Current).Row["name"] = b;
this.Validate();
fatemeBindingSource1.EndEdit();
fatemeTableAdapter.Update(this.baziDataSet1.fateme);
}</pre>
that program in first time add a record to database and grid but in secend time show message error column code can not be null.
and one problem in select a new row in grid when a type a value for a column that column is to be select and anather column not to be select and then in add record to sql one of column is 0 value. that how total record in select case.
please help me
:doh: :confused: :(
best a regards
best a regards
Reply
Answers (
0
)
Beginner help
How to insert a new row in a "bindingsource"DataGridView row