473,383 Members | 1,840 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,383 software developers and data experts.

adding dynamic row wid unique id retrieved in the textbox

private void AddRecordToGrid()
{
try
{


if (Session["SampleDataTable"] == null)
{
dt.Columns.Add(new DataColumn("ID", typeof(string)));
dt.Columns.Add(new DataColumn("Qtr", typeof(string)));

dt.Columns.Add(new DataColumn("Exp", typeof(string)));
dt.Columns.Add(new DataColumn("Partner", typeof(string)));
dt.Columns.Add(new DataColumn("Net", typeof(string)));
dr = dt.NewRow();
}
else
{
dt= (DataTable)Session["SampleDataTable"];
}

dr = dt.NewRow();


if (dr.IsNull(0))
{
//dr = dt.NewRow();
dr[0] = txtD.Text;
dr[1] = cbQuarter.SelectedItem.Text;

dr[2] =Exp.Text;
dr[3] = txtPartner.Text;
dr[4] = lblNet.Text;
dt.Rows.Add(dr);
DataView dv = new DataView(dt);
grdBudget.DataSource = dv;
grdBudget.DataBind();
}
for (int i = 0; i < grdBudget.Rows.Count; i++)
{

if (!dr.IsNull(0))
{
if (txtBudgetID.Text != dr[0].ToString())
{
dr = dt.NewRow();
dr[0] = txtD.Text;
dr[1] = cboQuarter.SelectedItem.Text;

dr[2] = Exp.Text;
dr[3] = txtPartner.Text;
dr[4] = lblNet.Text;
dt.Rows.Add(dr);
DataView dv = new DataView(dt);
grdBudget.DataSource = dv;
grdBudget.DataBind();
}
}
}
Session["SampleDataTable"] = dt;

}


catch (Exception ex)
{
}


the problem i m facing wid this code id that the new data row is added every time when this function is called and it enters ito the loop of the if(dr.isnull(0)) . i want only the values with unique id shud be entered. if the value wid the existin id id entere, it shud not be allowed to enter.
Nov 6 '08 #1
0 743

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Terri | last post by:
I have a form with a multi-select combo. I dynamically build a SELECT statement, open a report, and set the recordsource to my dynamic SELECT statement. I count the records returned in the report...
4
by: Bas Groeneveld | last post by:
I am developing an ASP.NET application part of which consists of a data entry wizard defined by entries in a data table - ie the controls on each page of the wizard are determined by definitions in...
1
by: Sunil Sabir | last post by:
Dear All, Actually I am want to make a function which will take a list of ID numbers retrieved from the database and diplayed their details on the web page.On the Web Page I have a textbox and...
4
by: Tim::.. | last post by:
Hi, Can someone please tell me the best way to create a web form on the fly according to a users input??? EG: If a user chooses the number 3 from a dropdownlist 3 textbox items are created......
0
by: Luis Esteban Valencia | last post by:
Hello I wrote a program with code behind in C# to add row into table dynamically and the program worked very well in .Net Framework 1.1. When I run this program in .Net Framework 2.0 beta...
0
by: fish | last post by:
I am new to .NET and am looking for a way to create a dynamic list of textboxes. Basically, the form begins with a row of three textboxes and the user can add another row (as many as they choose)...
2
by: johnb41 | last post by:
I want to create a textbox programmatically and add the SAME textbox to to different panels. This code does not work: Dim tb As New TextBox tb.text = "xyz" Panel1.Controls.Add(tb)...
2
by: Ken Fine | last post by:
I want to add the security question and answer security feature to the ChangePassword control. I am aware that this functionality is built into the PasswordRecovery tool. I have implemented the...
4
by: marisenthil | last post by:
How to access the value of the dynamic textbox by its id? I created more dynamic textbox using the below in loop Dim tb As New TextBox tb.ID = "txt_" + Str$(i) and it assigned unique...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.