Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all 5678 articles
Browse latest View live

update Sharepoint list and refersh/reload data on datatable (bootstrap)

$
0
0

Hi,

I have created table like this

$(document).ready(function () {
        $('#tbldocApproved').DataTable({
            "lengthMenu": [[5, 25, 50, -1], [5, 25, 50, "All"]],
            "pagingType": "simple_numbers",
            destroy: true
        });
    });

after inserting/updating record I can make those changes on particular row using

$(rowid).remove() //// and so on

problem:

I want to refresh datatable, I am trying to use like this "tbldocApproved'" its id of html table which is created like this 

<div style="background-color: transparent; border-image-outset: 0; border-image-repeat: stretch; border-image-slice: 100%; border-image-source: none; border-image-width: 1; color: #333333; font-family: &quot; segoe ui&quot;,&quot;lucida grande&quot;,verdana,arial,helvetica,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; outline-color: invert; outline-style: none; outline-width: 0px; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px; padding: 0px; margin: 0px; border: 0px none #333333;"> <table id="tbldocApproved" class="table table-striped table-bordered table-sm" cellspacing="0" width="100%"></div> <div style="background-color: transparent; border-image-outset: 0; border-image-repeat: stretch; border-image-slice: 100%; border-image-source: none; border-image-width: 1; color: #333333; font-family: &quot; segoe ui&quot;,&quot;lucida grande&quot;,verdana,arial,helvetica,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; outline-color: invert; outline-style: none; outline-width: 0px; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px; padding: 0px; margin: 0px; border: 0px none #333333;">

     ---

     ---

    </table>

I used this to refresh datatable:

  var ref = $('#tbldocApproved').DataTable();

</div>

            ref.ajax.reload(null, false);

its giving below error

"Datatable warning:table I="tbldocapproved-invalid json response.for more information about this error please see http:datables.net"


freetextbox is postback or refreshed with asp.net timer

$
0
0

have wrapped up the freetextbox editor inside updatepanel but it still keep refreshing maybe caused by timer tick,

tried enablepartialrendering="true" inside script manager wont make difference

<asp:Timer ID="FieldTimer2" runat="server" Interval="1000" OnTick="FieldTimer2_Tick" /></ContentTemplate><Triggers><asp:AsyncPostBackTrigger ControlID="FieldTimer2" EventName="Tick" /></Triggers></asp:UpdatePanel>
...<asp:UpdatePanel ID="udpfreetextbox" runat="server"><ContentTemplate><FTB:FreeTextBox id="FreeTextBox1" runat="Server"  /></ContentTemplate></asp:UpdatePanel>

using MVC and Ajax on checkbox from list Change select other checkboxes

$
0
0

hi

I have list of checkboxes. When an checkbox is selected it is sent Get to the controller and the controller should return list of dependent Ids that need to be checked too. For example: if checkbox with ID 1 is checked, the controler should return list of dependent ids like {5,6,7} and the sheckboxes with ids {5, 6, 7} should be checked. here  is my code:

view:

 @for (var i = 0;  i < Model.DocumentTypes.Count;     ++i)
{<tr><td><div class="custom-control custom-checkbox"><input type="checkbox" id="@Model.DocumentTypes.ElementAt(i).Key" onclick="FindDependentDocumentTypes(@Model.DocumentTypes.ElementAt(i).Key)"><label class="custom-control-label" for="@Model.DocumentTypes.ElementAt(i).Key">@Model.DocumentTypes.ElementAt(i).Value</label></div></td></tr>

}

<script>
    function FindDependentDocumentTypes(itemId) {$.get("/Home/GetDependents?i=" + itemId).done(function (data) {
            if (data.success) {
               // HERE I NEED HELP HOW TO CHECK ALL THE CHECKBOXES WHOSE iDS ARE IN THE LIST

            }
            else {
                alert(data.message);
            }
        });
    }
</script>

Controller

        [HttpGet]
        public ActionResult GetDependents(int i)
        {
            var List1 = GetDependentDocumentTypes(i);
            return View(List1);
        }

Please advice How to select the dependent checkboxes? 

JavaScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException

$
0
0

HI.

I am using VS 2010, C# and ASP.NET Web Application.

I am trying to export dataset to excel. I am getting an error as - JavaScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed.

The excel is not created. I have used the below code:

 DataSet ds = getDataSetExportToExcel(con);
                    using (XLWorkbook wb = new XLWorkbook())
                    {
                        wb.Worksheets.Add(ds);

                        Response.Clear();
                        Response.Buffer = true;
                        Response.Charset = "";
                        Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                        Response.AddHeader("content-disposition", "attachment;filename= " + filename1 + ".xlsx");
                        using (MemoryStream MyMemoryStream = new MemoryStream())
                        {
                            wb.SaveAs(MyMemoryStream);
                            MyMemoryStream.WriteTo(Response.OutputStream);

                            Response.Flush();
                            Response.End();
                        }
                    }

The error is at line - Response.End()

I have the scriptmanager added in the page with the below code:

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" AsyncPostBackTimeout="360000"></asp:ScriptManager><asp:UpdatePanel ID="upd1" runat="server"><ContentTemplate>

How to fix this?

Thanks

white square in the middle of Calendar extender

$
0
0

there is a white square in the center of the calendar of ajaxcontroltoolkit. what is strange is this happened suddenly without any previous actions in which in all the pages of my project is the same.

here is the screenshot of the problem https://1drv.ms/u/s!ArxL2goPTnKqpv9xUsW_sDKrDIZ0Xw

<asp:TextBox ID="TxtTodate" runat="server" MaxLength="10" Placeholder="DD/MM/YYYY" onkeypress="return false" onPaste="return false" onCopy="return false" onDrag="return false" onDrop="return false" /><ajaxToolkit:CalendarExtender ID="CalExtToDate" runat="server" Format="dd/MM/yyyy" TargetControlID="TxtTodate"></ajaxToolkit:CalendarExtender><span class="highlight"></span><span class="bar"></span><label>To</label>

Sum of three table in sql ?

$
0
0

i want this output  https://ibb.co/Jz98hwh

here is my data and query in which i have done one table section total ,and need to sum of second table and employee total

CREATE TABLE #Catagory (CID INT,CName VARCHAR(50))
CREATE TABLE #Sections (SecID INT,Secnam VARCHAR(50))
CREATE TABLE #ItemMasterFile(CodeItem INT,Descriptionitem VARCHAR(50),SecID INT,CID INT)
CREATE TABLE #Bigbalprd(BID INT,CodeItem INT,SecID INT,CID INT,QTY INT,Entrydate DATETIME)
CREATE TABLE #Probale(BID INT,CodeItem INT,prdQTY INT,Entrydate DATETIME)
CREATE TABLE #Employee(EID INT,SecID INT,QTY int, Entrydate DATETIME)

INSERT INTO #Catagory VALUES(1,'INDIA')
INSERT INTO #Catagory VALUES(2,'INDIA(Cut)')
INSERT INTO #Catagory VALUES(3,'Pakistan')
INSERT INTO #Catagory VALUES(4,'Pakistan(Cut)')


INSERT INTO #Sections VALUES(1,'HR')
INSERT INTO #Sections VALUES(2,'Baby')
INSERT INTO #Sections VALUES(3,'Ladies')
INSERT INTO #Sections VALUES(4,'Mix Rammage')

INSERT INTO #ItemMasterFile VALUES(1,'A',1,1)
INSERT INTO #ItemMasterFile VALUES(2,'B',2,2)
INSERT INTO #ItemMasterFile VALUES(3,'C',3,3)
INSERT INTO #ItemMasterFile VALUES(4,'D',4,null)
INSERT INTO #ItemMasterFile VALUES(5,'e',5,null)
INSERT INTO #ItemMasterFile VALUES(6,'f',6,null)
INSERT INTO #ItemMasterFile VALUES(7,'g',4,2)
INSERT INTO #ItemMasterFile VALUES(8,'h',4,3)
INSERT INTO #ItemMasterFile VALUES(9,'K',2,2)
INSERT INTO #ItemMasterFile VALUES(10,'L',4,3)
INSERT INTO #ItemMasterFile VALUES(11,'M',2,4)

INSERT INTO #Bigbalprd VALUES(1,1,1,1,1,'01-06-2019')
INSERT INTO #Bigbalprd VALUES(2,3,3,3,1,'02-06-2019')
INSERT INTO #Bigbalprd VALUES(3,4,null,4,1,'03-06-2019')
INSERT INTO #Bigbalprd VALUES(4,4,null,4,1,'04-06-2019')
INSERT INTO #Bigbalprd VALUES(4,5,null,4,1,'04-06-2019')

INSERT INTO #Probale VALUES(1,1,1,'01-06-2019')
INSERT INTO #Probale VALUES(2,3,1,'02-06-2019')
INSERT INTO #Probale VALUES(3,11,1,'03-06-2019')
INSERT INTO #Probale VALUES(4,10,1,'08-06-2019')
INSERT INTO #Probale VALUES(3,8,1,'03-06-2019')
INSERT INTO #Probale VALUES(4,9,1,'08-06-2019')
INSERT INTO #Probale VALUES(4,9,1,'08-06-2019')

INSERT INTO #Employee VALUES(1,1,4,'01-05-2019')
INSERT INTO #Employee VALUES(2,3,5,'02-05-2019')
INSERT INTO #Employee VALUES(3,3,3,'03-05-2019')
INSERT INTO #Employee VALUES(4,4,7,'04-05-2019')

DECLARE @StartDate DATETIME, @Enddate DATETIME
SET @StartDate = '01-06-2019'
SET @Enddate = '09-06-2019'

SELECT DISTINCT s.Secnam, ISNULL(SUM(b.prdQTY),0)QTY
FROM #ItemMasterFile i
LEFT OUTER JOIN #Probale b ON i.CodeItem = b.CodeItem
FULL OUTER JOIN #Sections s ON i.SecID = s.SecID

WHERE (b.Entrydate BETWEEN @StartDate AND @Enddate) OR b.Entrydate IS NULL
GROUP BY s.Secnam

DROP TABLE #Catagory
DROP TABLE #Sections
DROP TABLE #ItemMasterFile
DROP TABLE #Bigbalprd
Drop Table #Employee
Drop Table #Probale

Query is not giving correct output of Column (Small_Bale_Weight)

$
0
0

sql query is not giving proper result of Column (Small_Bale_Weight)

here is my complete data and query 

CREATE TABLE #Catagory (CID INT,CName VARCHAR(50))
CREATE TABLE #Sections (SecID INT,Secnam VARCHAR(50))
CREATE TABLE #ItemMasterFile(CodeItem INT,Descriptionitem VARCHAR(50),SecID INT,CID INT,weight int)
CREATE TABLE #Bigbalprd(BID INT,CodeItem INT,SecID INT,CID INT,Bpqty INT,Entrydate DATETIME , DelID int,Bweight int)
CREATE TABLE #Probale(BID INT,CodeItem INT,prdQTY INT,weight int,Entrydate DATETIME,DelID int)
CREATE TABLE #Emp_Strength(EID INT,SecID INT,QTY int, Entrydate DATETIME)

INSERT INTO #Catagory VALUES(1,'INDIA')
INSERT INTO #Catagory VALUES(2,'INDIA(Cut)')
INSERT INTO #Catagory VALUES(3,'Pakistan')
INSERT INTO #Catagory VALUES(4,'Pakistan(Cut)')


INSERT INTO #Sections VALUES(1,'HR')
INSERT INTO #Sections VALUES(2,'Baby')
INSERT INTO #Sections VALUES(3,'Ladies')
INSERT INTO #Sections VALUES(4,'Mix Rammage')

INSERT INTO #ItemMasterFile VALUES(1,'A',1,1,100)
INSERT INTO #ItemMasterFile VALUES(2,'B',2,2,100)
INSERT INTO #ItemMasterFile VALUES(3,'C',3,3,100)
INSERT INTO #ItemMasterFile VALUES(4,'D',4,null,100)
INSERT INTO #ItemMasterFile VALUES(5,'e',5,null,100)
INSERT INTO #ItemMasterFile VALUES(6,'f',6,null,100)
INSERT INTO #ItemMasterFile VALUES(7,'g',4,2,100)
INSERT INTO #ItemMasterFile VALUES(8,'h',4,3,100)
INSERT INTO #ItemMasterFile VALUES(9,'K',2,2,100)
INSERT INTO #ItemMasterFile VALUES(10,'L',4,3,100)
INSERT INTO #ItemMasterFile VALUES(11,'M',2,4,100)

INSERT INTO #Bigbalprd VALUES(1,1,1,1,1,'01-06-2019',null,100)
INSERT INTO #Bigbalprd VALUES(2,3,3,3,1,'02-06-2019',null,100)
INSERT INTO #Bigbalprd VALUES(3,4,null,4,1,'03-06-2019',null,100)
INSERT INTO #Bigbalprd VALUES(4,4,null,4,1,'04-06-2019',null,100)
INSERT INTO #Bigbalprd VALUES(4,5,null,4,1,'04-06-2019',null,100)

INSERT INTO #Probale VALUES(1,1,1,100,'01-06-2019',null)
INSERT INTO #Probale VALUES(2,3,1,200,'02-06-2019',null)
INSERT INTO #Probale VALUES(3,11,1,200,'03-06-2019',null)
INSERT INTO #Probale VALUES(4,10,1,200,'08-06-2019',null)
INSERT INTO #Probale VALUES(3,8,1,200,'03-06-2019',null)
INSERT INTO #Probale VALUES(4,9,1,200,'08-06-2019',null)
INSERT INTO #Probale VALUES(4,9,1,200,'08-06-2019',null)

INSERT INTO #Emp_Strength VALUES(1,1,4,'01-05-2019')
INSERT INTO #Emp_Strength VALUES(2,3,5,'02-05-2019')
INSERT INTO #Emp_Strength VALUES(3,3,3,'03-05-2019')
INSERT INTO #Emp_Strength VALUES(4,4,7,'04-05-2019')

DECLARE @StartDate DATETIME, @Enddate DATETIME
SET @StartDate = '01-06-2019'
SET @Enddate = '09-06-2019'

;WITH emp

as
(
select Secnam,ISNULL(sum(e.qty),0) Employee_QTY from #Sections s
left join #Emp_Strength e on s.secid=e.secid
where (Entrydate BETWEEN @StartDate AND @Enddate or Entrydate is null)
group by Secnam
),cte
AS
(
SELECT DISTINCT Sec.Secnam,
ISNULL(SUM(b1.Bpqty),0)Bigbale_QTY,ISNULL(sum(b1.Bweight),0)Bigbale_Weight,
ISNULL(SUM(b.prdQTY),0)Smallbale_QTY,ISNULL(SUM(i.weight),0)Small_Bale_weight
--ISNULL(SUM(emp.QTY),0)Employee_QTY
FROM #ItemMasterFile i
LEFT OUTER JOIN #Probale b ON i.CodeItem = b.CodeItem
LEFT OUTER JOIN #Bigbalprd b1 ON i.CodeItem = b1.CodeItem
Full Outer Join #Sections sec on i.SecID=sec.SecID
--left join Emp_Strength emp on emp.SecID = sec.SecID
--FULL OUTER JOIN Sections s ON i.SecID = s.SecID
where (b.DelID is null and b.Entrydate BETWEEN @StartDate AND @Enddate or b.EntryDate is null )
and
(b1.DelID is null and b1.EntryDate BETWEEN @StartDate AND @Enddate or b1.EntryDate is Null )


GROUP BY sec.Secnam
) SELECT cte.secnam, Smallbale_QTY,Small_Bale_weight, Bigbale_QTY, Bigbale_Weight,
( SELECT SUM(val)
FROM (VALUES (Bigbale_QTY)
, (Smallbale_QTY)

) AS value(val)
) AS Total_QTY,
( SELECT SUM(val)
FROM (VALUES (Bigbale_Weight),
(Small_Bale_weight )
)AS value(val)
) AS Total_Weight ,coalesce(Employee_QTY,0) Employee_QTY
FROM cte left join emp on cte.secnam=emp.secnam

HERE IS MY OUTPUT IN WHICH COLUMN OF SMALL BALE WEIGHT  RESULT IS NOT COMING CORRECT..

HERE IS LINK OF MY RESULT IMAGE   (https://ibb.co/TBXFzyq)

Image

//toolkit366.rssing.com/chan-4177202/article5488-live.html

$
0
0

Hi All,

I have <cc1:CalendarExtender  on my web form.

When page loads first time it shows blank even by selecting an invisible date doesn't comes in the text box, but when I click again on text box it shows  calendar with out any issue.

<asp:TextBox ID="txtStartDate" name="Star tDate" title="<%$Resources:Resource, traning_start %>"  autocomplete="off" MaxLength="20" runat="server" CssClass="form-control" EnableViewState="true"></asp:TextBox><cc1:CalendarExtender ID="ceDateFrom" runat="server" TargetControlID="txtStartDate"  Format="MM/dd/yyyy" ></cc1:CalendarExtender>

Untitled

Please suggest
 


JQuery Question with listbox

$
0
0

I have a listbox on my webpage, How do I use jquery to grab ALL items in the list box?

The item in  the listbox does not have to be selected, that just need to be listed and Jquery will grab them and pass the values to ajax json action.

Please help

Calculating Percentage row wise but it just given % of one row

$
0
0
CREATE TABLE #Category (CID INT,CName VARCHAR(50));
CREATE TABLE #Sections (SecID INT,Secnam VARCHAR(50));
CREATE TABLE #ItemMasterFile(CodeItem INT,Descriptionitem VARCHAR(50),SecID INT,CID INT,weight int);
CREATE TABLE #Bigbalprd(BID INT,CodeItem INT,SecID INT,CID INT,Bpqty INT,Entrydate DATETIME , DelID int,Bweight int);
CREATE TABLE #Probale(BID INT,CodeItem INT,prdQTY INT,weight int,Entrydate DATETIME,DelID int);
CREATE TABLE #Emp_Strength(EID INT,SecID INT,QTY int, Entrydate DATETIME);
GO
INSERT INTO #Category VALUES(1,'INDIA'),(2,'INDIA(Cut)'),(3,'Pakistan'),(4,'Pakistan(Cut)')
INSERT INTO #Sections VALUES(1,'HR'),(2,'Baby'),(3,'Ladies'),(4,'Mix Rammage'),(5,'T-Shirst'),(6,'Scrap'),(7,'Scrit'),(8,'Men'),(9,'HHR'),(10,'Sports'),(11,'m-HR'),(12,'M-Baby'),(13,'M-Ladies'),(14,'M-Mix Rammage'),(15,'m--Shirst'),(16,'M-Scrap'),(17,'M-Scrit'),(18,'M-Men'),(19,'M-HHR'),(20,'M-Sports');;

INSERT INTO #ItemMasterFile VALUES(1,'A',1,1,100)
, (2,'B',2,2,100)
, (3,'C',3,3,100)
, (4,'D',4,null,100)
, (5,'e',5,null,100)
, (6,'f',6,null,100)
, (7,'g',4,2,100)
, (8,'h',4,3,100)
, (9,'K',2,2,100)
, (10,'L',4,3,100)
, (11,'M',2,4,100);
INSERT INTO #Bigbalprd VALUES(1,1,1,1,1,'01-06-2019',null,100)
, (2,3,3,3,1,'02-06-2019',null,100)
, (3,4,null,4,1,'03-06-2019',null,100)
, (4,4,null,4,1,'04-06-2019',null,100)
, (4,5,null,4,1,'04-06-2019',null,100);

INSERT INTO #Probale VALUES(1,1,1,100,'01-06-2019',null)
, (2,3,1,200,'02-06-2019',null)
, (3,11,1,200,'03-06-2019',null)
, (4,10,1,200,'08-06-2019',null)
, (3,8,1,200,'03-06-2019',null)
, (4,9,1,200,'08-06-2019',null)
, (4,9,1,200,'08-06-2019',null);

INSERT INTO #Emp_Strength VALUES(1,1,4,'01-05-2019')
, (2,3,5,'02-05-2019')
, (3,3,3,'03-05-2019')
, (4,4,7,'04-05-2019');

DECLARE @StartDate DATETIME, @Enddate DATETIME
SET @StartDate = '01-06-2019'
SET @Enddate = '09-06-2019'

;WITH emp

as
(
select Secnam,ISNULL(sum(e.qty),0) Employee_QTY from #Sections s
left join #Emp_Strength e on s.secid=e.secid
where (Entrydate BETWEEN @StartDate AND @Enddate or Entrydate is null)
group by Secnam
),cte
AS
(
SELECT DISTINCT Sec.Secnam, 
ISNULL(SUM(b1.Bpqty),0)Bigbale_QTY,ISNULL(sum(b1.Bweight),0)Bigbale_Weight,
ISNULL(SUM(b.prdQTY),0)Smallbale_QTY,ISNULL(SUM(case when b.prdQTY is null then 0 else  i.weight end ),0)Small_Bale_weight
--ISNULL(SUM(emp.QTY),0)Employee_QTY
FROM #ItemMasterFile i
LEFT OUTER JOIN #Probale b ON i.CodeItem = b.CodeItem
LEFT OUTER JOIN #Bigbalprd b1 ON i.CodeItem = b1.CodeItem
Full Outer Join #Sections sec on i.SecID=sec.SecID
--left join Emp_Strength emp on emp.SecID = sec.SecID
--FULL OUTER JOIN Sections s ON i.SecID = s.SecID
where (b.DelID is null and b.Entrydate BETWEEN @StartDate AND @Enddate or b.EntryDate is null ) 
and
(b1.DelID is null and b1.EntryDate BETWEEN @StartDate AND @Enddate or b1.EntryDate is Null )

GROUP BY sec.Secnam
),cte1 as ( 
SELECT cte.secnam, Smallbale_QTY,Small_Bale_weight, Bigbale_QTY, Bigbale_Weight, 
( SELECT SUM(val) 
FROM (VALUES (Bigbale_QTY)
, (Smallbale_QTY)

) AS value(val)
) AS Total_QTY,

( SELECT SUM(val) 
FROM (VALUES (Bigbale_Weight),
(Small_Bale_weight )
)AS value(val)
) as Total_Weight,

--For Percentage--

( Select (ISNULL(Small_Bale_weight,0))/((SELECT SUM(val) 
FROM (VALUES (Bigbale_Weight),
(Small_Bale_weight )
)AS value(val)
))*100.0) as Percentage,


coalesce(Employee_QTY,0) Employee_QTY
FROM cte left join emp on cte.secnam=emp.secnam
group by cte.secnam,cte.Smallbale_QTY,cte.Bigbale_Weight,cte.Small_Bale_weight,cte.Bigbale_QTY,emp.Employee_QTY)



select * from cte1
where  Smallbale_QTY+Small_Bale_weight+Bigbale_QTY+Bigbale_Weight+Total_QTY+Total_Weight+Employee_QTY<>0

here is my output   https://ibb.co/Kmw1TmN

Image

UpdatePanel with Timer, enabled based on database value

$
0
0

Hi,

I have an UpdatePanel on each of my content pages. I want to add some form of timer control that can be enabled/disabled by getting the (boolean) value from the database on page load, as well as dynamically updating its Enabled/Disabled state with jQuery.

So the process would be:

full page load get true | false value from db for timer
if enabled run every x seconds, if disabled do nothing
somebody presses the Timer button that toggles the state in the database, and changes the state of the timer without a full page load/postback
if that change is to Enabled begin the timer, if that change is to Disabled stop the timer, both without a full page load/postback

If I use ASP.NET's Timer control, I can do the first part easily by populating the Enabled property with the value from the database. But, can client-side code dynamically change its state?

I am already doing 'manual' jQuery UpdatePanel postbacks elsewhere using this, so I wonder if a custom jQuery timer would be better:

page._doPostBack( 'ctl00$header$Search_Button', '' );

But can I enable/disable such a timer dynamically as well, and on page load?

Open to suggestions.

Thanks

autocomplete extender not finding service method

$
0
0

HI

Moving from VB to C# (still learning).  I have installed Ajax control toolkit and tested it with an accordion.  Thus I know the tool kit is installed correctly.

Have added a Webservice.asmx file and added reference to the service.  Added a button and text box and with code behind can reach the webservice method which returns a value (just test junk for the moment)

page markup for test button

<div>
<asp:Button ID="Button1" runat="server"
Text="Button"
OnClick="Button1_Click"
style="height: 26px" />
<br />
<asp:Label ID="Label1" runat="server"
Text="Label">
</asp:Label>
</div>

code behind for button

protected void Button1_Click(object sender, EventArgs e)
{
WebService webService = new WebService();
List<int> lstIntegers = new List<int> { 5, 6, 7 };
Label1.Text = "Output of WebService: " + webService.Add(lstIntegers).ToString();
}

and finally web method which works.

[WebMethod]
public int Add(List<int> listInt)
{
//https://www.c-sharpcorner.com/article/how-to-create-a-web-service-project-in-net-using-visual-studio/
int result = 0;
for (int i = 0; i < listInt.Count; i++)
{
result = result + listInt[i];
}
return result;
}

I run into troubles when I add a text box and and associated autocompleteextender.  (this works ok when I program using VB)

page markup for text box and autocompleteextender

<asp:TextBox ID="ImageNameSearchTextBox" runat="server"
style="width:100%">
</asp:TextBox>
<ajaxToolkit:AutoCompleteExtender ID="ImageNameSearchTextBox_AutoCompleteExtender" runat="server"
BehaviorID="ImageNameSearchTextBox_AutoCompleteExtender"
DelimiterCharacters=""
ServicePath="~/WebService.asmx"
ServiceMethod="Get_Image_Names"
CompletionInterval="10"
completionsetcount="10"
enablecaching="true"
MinimumPrefixLength="1"
TargetControlID="ImageNameSearchTextBox">
</ajaxToolkit:AutoCompleteExtender>

and associated web method. which should return a list of letters.

public List<string> Get_Image_Names(string prefixText, int count)
{
//https://www.aspdotnet-suresh.com/2011/03/how-to-implement-auto-complete-textbox.html
List<string> my_list = new List<string>();
my_list.Add("ab");
my_list.Add("ak");
my_list.Add("kl");
my_list.Add("kk");
return my_list;
}

What am I missing?  

Thanks in advance for any help!

jQuery are not working in full page update panel in asp.net webforms

$
0
0

Jquery is not working while full-page Update Panels are used in ASP .Net webforms. The issue I am facing is that when I apply update panel on the full page then Jquery function is not working. (For example: when I click on bootstrap dropdown so dropdown are showing for 1 second and automatically  disappear)

The problem with is that I want Jquery to fully work (no need to reload it again) while any partial postback request from UpdatePanels in ASP .Net occurs.

<asp:Content ID="content4" runat="server" ContentPlaceHolderID="ContentPlaceHolder1"><asp:ScriptManager ID="ScriptManager2" runat="server"></asp:ScriptManager><script>
         //import dropdown-menu script$("document").ready(function () {$('.dropdown-menu').on('click', function (e) {
                 if ($(this).hasClass('dropdown-menu-form')) {
                     e.stopPropagation();
                 }
             });$('.dropdown-menu').on('click', function (e) {
                 if ($(this).hasClass('dropdown-menu-showhide')) {
                     e.stopPropagation();
                 }
             });
         });</script><style>
         /*import dropdown-menu css*/
.dropdown-menu-form {
   min-width:192px;
}     
.dropdown-menu-form > li > a{
    padding:8px 18px;
}
.dropdown-header-imp{
    font-weight: 600;
    background-color: #f1f3f6;
    padding-bottom: 6px;
    color: #6a6c6f;
    font-size: 14px;
    padding-top: 6px;
    padding-left: 17px;
}
.dropdown-menu-form li a:hover{
    background-color:#6a6c6f;
    color:#fff;
    transition: all 0.4s ease 0s;   
}
         /*Show Hide col dropdown-menu css*/
.dropdown-menu-showhide{
   min-width:250px;
   height:300px;
   overflow-y:scroll;
}     
.dropdown-menu-showhide > li {
    padding:6px 8px;
}
.dropdown-header-showhide{
    font-weight: 600;
    background-color: #f1f3f6;
    padding-bottom: 6px;
    color: #6a6c6f;
    font-size: 14px;
    text-align:center;
    padding-top: 6px;
    padding-left: 17px;
}

.dropdown-menu-showhide li:hover{
    background-color:#f1f3f6;
    color:#6a6c6f;
    transition: all 0.4s ease 0s;   
}
    </style>    <asp:PlaceHolder runat="server" ID="PlaceHolder2" /><asp:UpdatePanel ID="UpdatePanel2" runat="server" ChildrenAsTriggers="true"><ContentTemplate><div class="row"><div class="col-md-9"><div class="form-group pull-right"><div><asp:LinkButton ID="LinkButton1" CssClass="btn btn-primary" runat="server" ToolTip="Insert New Vendor" data-toggle="tooltip" data-placement="top" OnClick="InsertVendorImageButton_Click"><i class="fa fa-plus" aria-hidden="true"></i> Add</asp:LinkButton><asp:LinkButton ID="LinkButton2" CssClass="btn btn-info" runat="server" data-toggle="tooltip" data-placement="top" ToolTip="Update Selected Vendor(s) Record" OnClick="UpdateVendorImageButton_Click"><i class="fa fa-pencil-square-o" aria-hidden="true"></i> Edit</asp:LinkButton><asp:LinkButton ID="LinkButton3" CssClass="btn btn-danger" runat="server" data-toggle="tooltip" data-placement="top" ToolTip="Delete Selected Vendor(s) Record" OnClientClick="return DeleteRecord();" OnClick="DeleteVendorImageButton_Click"><i class="fa fa-trash" aria-hidden="true"></i> Delete</asp:LinkButton></div></div></div></div><asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Always"><Triggers><asp:AsyncPostBackTrigger ControlID="CheckBoxEmail" EventName="CheckedChanged" /></Triggers><ContentTemplate><asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0"><asp:View ID="View1" runat="server"><div class="row"><div class="col-lg-12"><div class="hpanel hblue"><div class="panel-heading hbuilt"><div class="panel-tools"><div class="small text-bold left">
                                                    Show&nbsp;<asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"><asp:ListItem Value="1">5</asp:ListItem><asp:ListItem Value="2" Selected="True">10</asp:ListItem><asp:ListItem Value="3">20</asp:ListItem><asp:ListItem Value="4">50</asp:ListItem><asp:ListItem Value="5">100</asp:ListItem><asp:ListItem Value="6">500</asp:ListItem></asp:DropDownList>&nbsp;entries</div><a class="dropdown-toggle" href="#" data-toggle="dropdown"><i class="fa  fa-cog"></i></a><ul class="dropdown-menu dropdown-menu-showhide pull-right" style="font-size: 14px;"><li class="dropdown-header-showhide">Show Hide Column</li><li><div class="checkbox checkbox-primary"><asp:CheckBox ID="CheckBox1" Checked="true" runat="server" Text="Email" AutoPostBack="true" /></div></li><li><div class="checkbox checkbox-primary"><asp:CheckBox ID="CheckBox3" Checked="true" runat="server" Text="Skype ID" /></div></li><li><div class="checkbox checkbox-primary"><asp:CheckBox ID="CheckBox4" Checked="false" runat="server" Text="Tax" /></div></li></ul></div><h3 class="panel-heading-primary-h3">Vendor(s)</h3></div><div class="panel-body"><div class="row"><div class="col-lg-4 pull-right"><div class="form-group"><input type="text" id="txt_search" class="form-control" placeholder="Search Vendor(s)..." data-toggle="tooltip" data-placement="top" title="Search Vendor(s)" /><%--<asp:TextBox ID="VendorTextBox" runat="server" CssClass="form-control" placeholder="Search Vendor(s)..." data-toggle="tooltip" data-placement="top" ToolTip="Search Vendor(s) "></asp:TextBox> --%></div></div></div><asp:HiddenField ID="HiddenField1" runat="server" /><div class="row"><div class="col-lg-12"><div class="table-responsive"><asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" AllowPaging="true" PageSize="10" PagerSettings-Position="Bottom" OnPageIndexChanging="VendorGridView_PageIndexChanging"
                                                            EnableModelValidation="True" OnRowCommand="CustomerGridView_RowCommand" CssClass="webposgridview-primary" AlternatingRowStyle-CssClass="alt" PagerStyle-CssClass="pgr" AllowSorting="true" OnSorting="VendorGridView_Sorting" ShowFooter="true" OnRowCreated="VendorGridView_RowCreated"><Columns><asp:TemplateField HeaderText="Select" HeaderStyle-Width="10px" HeaderStyle-HorizontalAlign="Center" HeaderStyle-VerticalAlign="Bottom" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Bottom"><HeaderTemplate><div class="checkbox checkbox-primary" data-toggle="tooltip" data-placement="top" title="Select All Records"><input id="Checkbox2" type="checkbox" onclick="CheckAll(this)" runat="server" aria-label="Single checkbox One" /><label></label></div></HeaderTemplate><ItemTemplate><div class="checkbox checkbox-primary"><asp:CheckBox ID="SelectCheckBox_item" runat="server" /><label></label></div></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="Vendor ID" Visible="false"><ItemTemplate><asp:Label ID="VendorLabel_item" runat="server" Text='<%# Eval("VendorID") %>'></asp:Label></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="Vendor(s) Name<span class='fa fa-sort-alpha-asc gridview-desc-ion'></span>" SortExpression="VendorName"><ItemTemplate><asp:Label ID="VendorNameLabel" runat="server" Text='<%# Eval("VendorName") %>'></asp:Label></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="E-Mail"><ItemTemplate><asp:Label ID="ZIPLabel" runat="server" Text='<%# Eval("Email") %>'></asp:Label></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="View Detail" HeaderStyle-Width="110px"><ItemTemplate><%--<asp:ImageButton ID="detailImageButton_item" runat="server" 
                        CommandName="Detail" CommandArgument='<%#Eval("CustomerID") %>' 
                        Height="18px" ImageUrl="~/Images/customerdetail1.png" Width="70px" />--%><asp:LinkButton ID="detailImageButton_item" runat="server" CommandName="Detail" CssClass="btn btn-default btn-sm" CommandArgument='<%#Eval("VendorID") %>' data-toggle="tooltip" data-placement="left" ToolTip="View Detail"><i class="ion-eye"></i> View</asp:LinkButton></ItemTemplate><ItemStyle HorizontalAlign="Center" VerticalAlign="Top" /></asp:TemplateField></Columns><PagerSettings Mode="NumericFirstLast" PageButtonCount="20" /></asp:GridView></div></div></div></div></div></div></div></asp:View><asp:View ID="View2" runat="server"><div class="row"><div class="col-lg-12"><div class="hpanel hblue"><div class="panel-heading hbuilt text-center"><label id="Label3" runat="server" class="panel-inner-heading-primary-h3"></label></div><div class="panel-body"><div class="row"><div class="col-lg-4"><div class="form-group"><asp:HiddenField ID="HiddenField2" runat="server" /><label>Company Name:</label><asp:TextBox ID="TextBox3" CssClass="form-control" runat="server"></asp:TextBox></div></div><div class="col-lg-4"><div class="form-group"><label>Email Address:</label><asp:TextBox ID="TextBox4" runat="server" CssClass="form-control" /></div></div><div class="col-lg-4"><div class="form-group"><label>Tax Number:</label><asp:TextBox ID="TextBox5" runat="server" CssClass="form-control" /></div></div></div><script>
                                                Sys.Application.add_load(initdropdownInsertCategoryDDL);</script><div class="row"><div class="col-lg-4"><div class="form-group"><label>Classes</label><asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="InsertCategoryDDL" Display="Dynamic" ErrorMessage="Please Select Category and then Press Save" InitialValue="0" Text="<i class='ion-ios-medical'> </i>" ToolTip="Please Select Category and then Press Save" ValidationGroup="InsertCategoryGrp" /><asp:Panel ID="Panel1" runat="server"><asp:DropDownList ID="DropDownList4" runat="server" AutoPostBack="True" OnSelectedIndexChanged="InsertCategoryDDL_SelectedIndexChanged" CssClass="form-control js-source-states"></asp:DropDownList></asp:Panel></div></div><div class="col-lg-8"><div class="form-group"><label>Details:</label><asp:TextBox ID="TextBox9" runat="server" CssClass="form-control" Style="resize: none" /></div></div></div><div class="row"><div class="col-lg-12"><div class="form-group"><asp:PlaceHolder ID="PlaceHolder3" runat="server"></asp:PlaceHolder><asp:LinkButton ID="LinkButton8" runat="server" OnClick="ClearClassLinkButton_Click">Clear Classes</asp:LinkButton></div></div></div><div class="row"><div class="col-lg-12 col-md-6"><div class="page-header"><h4 style="text-align: center;">Contact Information</h4></div></div></div></div><div class="panel-footer" id="test1"><asp:LinkButton ID="LinkButton9" CssClass="btn btn-primary" runat="server" CausesValidation="false" ValidationGroup="InsertGrp" OnClientClick="return SaveOrUpdate();" OnClick="InsertLinkButton_Click"> Save</asp:LinkButton><asp:LinkButton ID="LinkButton10" CssClass="btn btn-danger" runat="server" ValidationGroup="ClearGrp" OnClick="ClearLinkButton_Click"> Clear</asp:LinkButton></div></div></div></div></asp:View></asp:MultiView></ContentTemplate></asp:UpdatePanel></ContentTemplate><Triggers><asp:PostBackTrigger ControlID="btnExportSelected" /><asp:PostBackTrigger ControlID="btnExportAll" /><asp:AsyncPostBackTrigger ControlID="ConvertionExportDDL" /><asp:AsyncPostBackTrigger ControlID="IDButtonSettings" /><asp:AsyncPostBackTrigger ControlID="IDCheckBoxListMain" /><asp:PostBackTrigger ControlID="CheckBoxTax" /><asp:PostBackTrigger ControlID="CheckBoxBankName" /><asp:PostBackTrigger ControlID="CheckBoxBankAccountNo" /><asp:PostBackTrigger ControlID="CheckBoxClasses" /><asp:PostBackTrigger ControlID="CheckBoxAddress" /><asp:PostBackTrigger ControlID="CheckBoxVendorName" /><asp:PostBackTrigger ControlID="CheckBoxDetails" /></Triggers></asp:UpdatePanel></asp:Content>

Not getting return value on callback

$
0
0

I'm trying to use a callback to execute a query to count records based on a date and use a confirm to delete them. Everything is fine but for some reason, even though I cancel, a postback occurs anyway. I'm new to asynchronous callbacks so I'm not exactly sure how this is supposed to work given the different ways I've seen to do it. All the return values are correct in the script. There is a master page involved with most of the scripts being on that page because they are shared. This script is located at the bottom of the local page.

<script type="text/javascript" language="javascript">

	function checkRollOff() {

		PageMethods.PriorGigsInTable(onSuccess, onFailure);

		function onSuccess(result) {

			var retVal;

			if (result == true) {
				retVal = confirm("This will delete all gigs prior to the current date. Are you sure you want to do this?");
			}
			else {
				alert("There are no past gigs on the schedule...");
				retVal = false;
			}
			return retVal;

		}

		function onFailure(error) {
			alert(error);
		}

	}

</script>



[WebMethod]
public static bool PriorGigsInTable()
{
	//Return value based on successful operation
	if (ScheduleDataAccess.PriorGigsInTable())
		return true;
	else
		return false;

}

 

Autocomplete not firing after uploading to server

$
0
0

Hi

I have a text box with an associated autocompleteextender and web service .asmx page that work correctly on my development machine.  I publish to a subdirectory on my machine and then upload the files to my website on the server.

Unfortunately, the autocomplete does not respond on the server.  I get 2 errors (using F12) as follows.

POST MsAjaxJs?v=D6VN0fHlwFSIWjbVzi6mZyE9Ls-4LNrSSYVGRU46XF81:1 POST http://pictures.jerripediabmd.net/WebService.asmx/Get_Image_Names 500 (Internal Server Error) MsAjaxJs?v=D6VN0fHlwFSIWjbVzi6mZyE9Ls-4LNrSSYVGRU46XF81:1

Uncaught TypeError: Cannot read property 'webServiceFailedNoMsg' of undefined
at Array.it (MsAjaxJs?v=D6VN0fHlwFSIWjbVzi6mZyE9Ls-4LNrSSYVGRU46XF81:1)
at MsAjaxJs?v=D6VN0fHlwFSIWjbVzi6mZyE9Ls-4LNrSSYVGRU46XF81:1
at Sys.Net.WebRequest.completed (MsAjaxJs?v=D6VN0fHlwFSIWjbVzi6mZyE9Ls-4LNrSSYVGRU46XF81:1)
at XMLHttpRequest._onReadyStateChange (MsAjaxJs?v=D6VN0fHlwFSIWjbVzi6mZyE9Ls-4LNrSSYVGRU46XF81:1)

Any suggestions as to where I need to look to find/correct this problem?

Thanks in advance.


Ajax infinite scroll only triggering once on page end

$
0
0

I can't work out why this is not working. When I scroll to the end it triggers the Ajax and gives me html which appends to the element, however this only works once, if I keep scrolling it doesn't work again so it's not endless scroll. Anyone know what I'm doing wrong here ? 

   <script>

    $(document).scroll(function(e){

        if($(document).scrollTop()+$(window).height()>$(document).height()-1000){

            $(document).off('scroll');

            //$('html, body').stop();

            $.ajax({

                type:"GET",

                url:"/home/getFreshAJAX_Post/",

                data: null

            }).done(function(viewHTML){

                //alert('The count of the html characters in the view is; ' + viewHTML.count)

                $("#appendContentHere ").append(viewHTML);

                $('#index_count').attr('value', viewHTML.index_count);

                if (viewHTML.count !=0) {

                    $(document).scroll(function(e){

                        //callback to the method to check if the user scrolled to the last element of your list/feed

                    })

                }

            });

        };

    });

    </script>

I am trying to close modelpopupextender using a button click, this button belongs to another form so modelpopupextender is not able to accessable.

$
0
0

I have tried to remove the updatepanel as suggested, but it's not working.

 

This is my form1.aspx (which includes a button, onclick which will display a ModalPopupExtender in which includes grid view)

 

<asp:Button id="btnclick" text="Show Modal Popup" runat="server" >

</asp:Button>

<cc1:ModalPopupExtender ID="ModelPopupExtender1" runat="server"

PopupControlID="pc" TargetControlID="btnclick" OkControlID ="Button2"

CancelControlID="Button1" BackgroundCssClass="bcc" BehaviorID="MPE1">

</cc1:ModalPopupExtender>

<asp:Panel ID="pc" runat="server" CssClass="pop" Style="display:none;">

<iframe style="width:1003px;height:550px;" id="if"src="EstPopUp.aspx" runat="server"></iframe>

</asp:Panel>

 

This is my EstPopUp.aspx ( Where gridview is dislpayed with save and cancel buttons)

 

<asp:GridView ID="gvContacts" runat="server" AutoGenerateColumns="false" CellPadding="5"  DataKeyNames="EstimateBreakUpTypeId" OnSelectedIndexChanged="gvContacts_SelectedIndexChanged" OnRowDataBound="gvContacts_RowDataBound" >

<Columns>

<asp:TemplateField HeaderText="DispOrder">

<ItemTemplate>

<center>

<asp:TextBox ID="TextBox1" width="20px" runat="server" Text='<%#

Bind("DispOrder") %>'></asp:TextBox>

</center>

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateField HeaderText="EstBreakUpName">

<ItemTemplate>

<asp:DropDownList ID="DropDownList1" runat="server"  ></asp:DropDownList>

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateField HeaderText="Percentage(%)">

<ItemTemplate>

<center>

<asp:TextBox ID="TextBox2" Width="30px" runat="server"></asp:TextBox>

</center>

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateField HeaderText="Amount">

<ItemTemplate>

<asp:TextBox ID="TextBox3"  runat="server" CssClass="sum"  ></asp:TextBox>

<cc1:FilteredTextBoxExtender ID="fte" runat="server" Enabled="true"

TargetControlID="TextBox3" FilterType="Numbers,Custom" ValidChars=".">

</cc1:FilteredTextBoxExtender>

</ItemTemplate>

</asp:TemplateField>

</Columns>

</asp:GridView>

<br/>

<asp:Button ID="Button1" runat="server" Text="Save" OnClick="Button1_Click"></asp:Button>      

<asp:Button class="abc" ID="Button2" runat="server" Text="Cancel" CssClass=".cancel" OnClick="Button2_Click1"></asp:Button >

<br />

 

</asp:GridView>

 

My expected result is, when cancel button is clicked the modelpopup should disappear.

google charts not appearing inside update panel

$
0
0

Hi ,

Iam working with below

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', { packages: ['corechart'] });
</script>

I have filters to show data in graph when I keep update panel for autopost back then charts does not work.I have checked multiple threads regarding this but i did not get any answer .Please suggest 

control with ID 'btnUpload_Click2' could not be found for the trigger in UpdatePanel 'UpdatePanel3'.

$
0
0

Getting this error message

System.InvalidOperationException: A control with ID 'btnUpload_Click2' could not be found for the trigger in UpdatePanel 'UpdatePanel3'.

[InvalidOperationException: A control with ID 'btnUpload_Click2' could not be found for the trigger in UpdatePanel 'UpdatePanel3'.]
   System.Web.UI.UpdatePanelControlTrigger.FindTargetControl(Boolean searchNamingContainers) +441246

Any ideas would be appreciated

Here is the Code

<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<<asp:LinkButton ID="LinkButton4" runat="server" CssClass="btn btn-success" OnClick="btnUpload_Click2" Width="161px">
<span class="glyphicon glyphicon-upload"></span> Upload and Resize
</asp:LinkButton>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger Controlid="btnUpload_Click2"></asp:PostBackTrigger>
</Triggers>
</asp:UpdatePanel>

How to insert DataValueField into database.... from gridview ?

$
0
0

i am inserting multiple data into gridview from dropdown list ,i have bind dropdownlist data from database where DataTextField and DataValueField  are coming....Now i want to store DatavalueField in session of multiple row of gridview data,,then i insert bulk data into database...

here is my code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;

namespace WebApplication1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        SqlConnection con = new SqlConnection("Data Source=DESKTOP-5PJ76B9;Integrated Security=SSPI;Initial Catalog=SPS;MultipleActiveResultSets=True;");
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindGrid();
                itemload();
            }
        }

        private void itemload()
        {
          
            con.Open();
            SqlDataAdapter adpr1 = new SqlDataAdapter("select * from ItemMasterFile ", con);
            DataSet dspr1 = new DataSet();
            adpr1.Fill(dspr1);
            DropDownList1.DataSource = dspr1.Tables[0];
            DropDownList1.DataTextField = "Descriptionitem";
            DropDownList1.DataValueField = "Codeitem";
            DropDownList1.DataBind();
        }

        private void BindGrid()
        {
            GridView1.DataSource = DataSource;
            GridView1.DataBind();
        }

        private DataTable DataSource
        {
            //-- this is the property that will retain the data source and data will keep on adding in there on button click
            get
            {
                DataTable dtSource = new DataTable();
                if (null != Session["__DataSource"])
                    dtSource = Session["__DataSource"] as DataTable;
                else
                    dtSource = GetDataFromDatabase();

                return dtSource;
            }

            set
            {
                Session["__DataSource"] = value;
            }
        }

        private DataTable GetDataFromDatabase()
        {
            //-- here is a sample code, that just generate data for Gridview, you will require to write code here to fetch data from Database.
            DataTable resultDt = new DataTable();
            resultDt.Columns.AddRange(
                new DataColumn[] {
        new DataColumn("Descriptionitem"),
        new DataColumn("QTY"),
            });

            for (int i = 0; i < 0; i++)
            {
                DataRow dr = resultDt.NewRow();
                //dr["Field1"] = "Field1 " + i.ToString();
                //dr["Field2"] = "Field2 " + i.ToString();
                //dr["Field3"] = "Field3 " + i.ToString();
                resultDt.Rows.Add(dr);
            }

            return resultDt;
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            DataTable dtSource = DataSource;
            DataRow dr = dtSource.NewRow();
            dr["Descriptionitem"] = DropDownList1.SelectedItem.Text.Trim();

           // dr["Descriptionitem"] = DropDownList1.Text.Trim();
            dr["QTY"] = txtqty.Text.Trim();

            dtSource.Rows.Add(dr);
            DataSource = dtSource;

            BindGrid();

            txtqty.Text = string.Empty;
        }
    }
}

Please Consider

Viewing all 5678 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>