7
Answers

Dynamic generate id

Akash Patil

Akash Patil

8y
321
1
Hello Experts,
 
 
i want to generate dynamic id for textbox and button.
 
$(document).ready(function () {
function addRow() {
var html = '<tr>' +
'<td><select id="txtName" class="form-control"><option> Select Product</option><option> VITA-H 100ml</option><option> CAL-CM GOLD</option></td>' +
'<td><input type="text" id="txtAmount" class="form-control" placeholder="Amount"></td>' +
'<td><input type="text" id="txtQyantity" class="form-control" placeholder="Qyantity" ></td>' +
'<td><input type="text" id="txtTotalAmount" class="form-control" placeholder="Total Amount"></td>' +
'<td><input type="button" id="btnadd" class="form-control btn btn-success" value="+ Add Product" /></td>' +
'<td><input type="button" id="btnremove" class="form-control btn btn-danger" value="- Remove Product" /></td>' +
'</tr>';
$(html).appendTo($("#Table1"));
};
/
$("#Table1").on("click", "#btnadd", addRow);
function deleteRow() {
var par = $(this).parent().parent();
par.remove();
};
};
});
 
when i click on "add product" button its add new row for product.But not getting different id for Textbox of new row. 
 
Please help me. 
 
Thank You 
Answers (7)
0
Amit Gupta

Amit Gupta

NA 16.5k 25.6k 8y
Hi Dear

Try to alter the query... use

Date>=@startDate and Date <=@enddate

// now pass the parameter as u r doing..

Hope it helps
0
Atul Rokade

Atul Rokade

NA 141 17k 8y
sir i implemented your code like this below
 
string connetionString = null;
connetionString = ConfigurationManager.ConnectionStrings["AccessConnectionString"].ConnectionString;
cnn.ConnectionString = connetionString;
cmd = new OleDbCommand("SELECT * FROM Billing " + "WHERE Date between ? AND ?");
cmd.Parameters.AddWithValue("?", dateTimePicker1.Value);
cmd.Parameters.AddWithValue("?", dateTimePicker2.Value);
OleDbConnection connection = new OleDbConnection(connetionString);
OleDbDataAdapter dataadapter=new OleDbDataAdapter ();
DataSet ds = new DataSet();
connection.Open();
dataadapter.SelectCommand = cmd;
connection.Close();
dataGridView1.DataSource = ds;
 
but now what happen if i select start_date suppose 1/02/2016 and end_date is 22/03/2016 and click show Report nothing is coming into datagridview but there is a one entry of 17/02/2016 date for refernce i given two image
 
 
 
 
0
Krishna Rajput Singh

Krishna Rajput Singh

NA 5.5k 2m 8y
you welcome Atul well helpful for you mark as correct answer
0
Krishna Rajput Singh

Krishna Rajput Singh

NA 5.5k 2m 8y
you welcome Atul well helpful for you mark as correct answer
0
Atul Rokade

Atul Rokade

NA 141 17k 8y
thank you krishna sir for reply i will check whatever links you given , thank you once again :)
0
Atul Rokade

Atul Rokade

NA 141 17k 8y
thank you sir for reply but m not understnd how i put datetimepicker in query all query which is given
0
Krishna Rajput Singh

Krishna Rajput Singh

NA 5.5k 2m 8y
Hello Atul Rokade thanks foe writing below links i hope helpful for you...:)
 
http://stackoverflow.com/questions/541225/how-can-i-set-a-datetimepicker-control-to-a-specific-date
 
http://stackoverflow.com/questions/19934793/set-datetimepicker-control-to-format-yyyymmdd
 
https://msdn.microsoft.com/en-us/library/ms229631(v=vs.110).aspx 
0
Suthish Nair

Suthish Nair

NA 31.7k 4.6m 8y
Am not sure what issue you are facing... try this...
cmd.CommandText =
"SELECT * FROM Billing " +
"WHERE Date Between ? And ?";
cmd.Parameters.AddWithValue("?", dateControl1.value/text);
cmd.Parameters.AddWithValue("?", dateControl2.value/text);
or
OleDbCommand command = new OleDbCommand(
"SELECT * FROM Billing " +
"WHERE Date between @DateStart AND @DateEnd");
command.Parameters.AddWithValue("@DateStart",dateTimePicker1.Value.Date);
command.Parameters.AddWithValue("@DateEnd",dateTimePicker2.Value.Date);