2
Answers

how to store gridview datas to sql database

ramya t

ramya t

8y
281
1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
This is my web form.In this form i have retrieved data's from two tables which is the supplierid and supplier company name datas are retrieved from Supplier table.Product id,product name,product price datas are retrieved from Product Table.Now i can connect Both tables in single form(above form).
 
i have select one supplier ,what product product the supplier to be supplied which is selected from listbox1 to listbox2.all the details should be loaded in to gridview by clicking load button like wise the gridview datas are stored in to another table 'SuppvsPro'.
Again I have select the same Supplier with prevoius product as well as some new products ,the datas are loaded in to gridview.but the table contains previous products as well as new loaded products,My expectation is the table contains only new datas with our duplication.
 
Please help me how can i solve this problem.
 
 
 Actual database value
Supplier id   SupplierCompany   Productid   ProductName   ProductPrice
Supp1            Pachaas                  app001      Apple                  80
Supp1              Pachaas                Cin001      Cinthol                 33
 
 The Supp1 supplied only these two products ,again I have add some product with thease products
 The database will be,
 
Supplier id    SupplierCompany    Productid     ProductName    ProductPrice
Supp1                Pachaas                app001          Apple                80
Supp1                 Pachaas                Cin001        Cinthol                33
Supp1                 Pachaas                 app001        Apple                80
Supp1                   Pachaas                Cin001        Cinthol                33
Supp1                  Pachaas                 Ham002        Hamam            31
 
My Expectation result is,
 
Supp1 Pachaas  app001   Apple   80
Supp1 Pachaas Cin001   Cinthol    33
Supp1 Pachaas Ham002  Hamam  31
 
without duplication.Please help me.Thank You
Answers (2)
1
Nitin Sontakke

Nitin Sontakke

NA 11.7k 2.2k 8y
How is it different is not clear to me. Can you please explain?
 
In fact, you already seem to have done it. So where is the problem?
 
You should also elaborate on "not working". Did you debug? In _DayRender event, is date variable getting correct value?
 
Accepted
0
Hold On

Hold On

NA 390 13.8k 8y
@Gnanavel Sekar , Thanks for your reply. I will also try this one.
0
Gnanavel Sekar

Gnanavel Sekar

NA 6.8k 452.1k 8y
Just set the minimum value for second calender once the date picked from first calender , for this you may use client side jquery to overcome this.
 example in click event
var arr = selectedDate.split("/");
var date = new Date(arr[2]+"-"+arr[1]+"-"+arr[0]);
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
var minDate = new Date(y, m, d + 1);
$("#EndDate").datepicker('setDate', minDate);
 
 
Refer below links
 
http://stackoverflow.com/questions/27721133/jquery-datepickers-setting-end-date-from-a-start-date
http://stackoverflow.com/questions/24894048/jquery-datepicker-how-to-set-start-and-end-date
http://stackoverflow.com/questions/17016598/jquery-ui-picking-a-start-and-end-date-within-range-based-on-start-date 
http://www.aspsnippets.com/Articles/jQuery-DatePicker-Start-Date-should-be-less-than-End-date-validation.aspx 
 
0
Hold On

Hold On

NA 390 13.8k 8y
@Nitin Sontakke
 
Thank you for pointing my mistake. I got it now. The problem is the ">", I changed it to "<" and now it worked!.
  1. protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)  
  2.         {  
  3.             DateTime date = Convert.ToDateTime(TextBox1.Text);   
  4.   
  5.             if (e.Day.Date < date)  
  6.             {  
  7.                 e.Cell.Enabled = false;  
  8.                 e.Day.IsSelectable = false;  
  9.             }  
  10.         }  
 
0
Hold On

Hold On

NA 390 13.8k 8y
@Nitin Sontakke
 
Yes I have seen it but it's a different scenario.  
0
Nitin Sontakke

Nitin Sontakke

NA 11.7k 2.2k 8y
Have you had a look at this?
 
http://stackoverflow.com/questions/10227417/setting-minimum-and-maximum-date-on-calendar