|
Hi,
As this is my first project, I really do not have much idea to debug this. I have a listview. I am writing code manually to populate listview. As the listview is very large, I have a search button where user enters a search string. I am trying to build a sql string from here and populate the listview. Everything works fine but when I click on next page, it does not include the search string. I think it is just populating the 2nd page without the search criteria. If I remove the data pager control, it works fine. I am not able to put proper code datapger_PagePropertiesChanging. I appreciate if someone can help me with this.
Here is my list view markup:
<div class="topcontent">
<asp:TextBox ID="txtSearch" runat="server" cssClass="txt"></asp:TextBox>
<cc1:TextBoxWatermarkExtender ID="tbwatermarkSearch" runat="server" TargetControlID="txtSearch" WatermarkText="Search Contractor..">
</cc1:TextBoxWatermarkExtender>
<asp:Button ID="btnSearch" runat="server" cssClass="btn" onClick="btnSearch_Click" Text="Search" />
</div>
<asp:ListView ID="lvContractors" runat="server" OnPagePropertiesChanging="lvContractors_PagePropertiesChanging">
<LayoutTemplate>
<div class="ListViewGrid">
<table class="tblpadding">
<tr>
<th class="HeaderStyle">
Contractor Number
</th>
<th class="HeaderStyle">
First Name
</th>
<th class="HeaderStyle">
Last Name
</th>
<th class="HeaderStyle">
View
</th>
<th class="HeaderStyle">
Edit
</th>
</tr>
<tbody><asp:PlaceHolder runat="server" ID="itemPlaceholder" /></tbody>
</table>
</div>
</LayoutTemplate>
<ItemSeparatorTemplate> <td> <hr /> </td>
</ItemSeparatorTemplate>
<ItemTemplate>
<div >
<tr>
<td class="RowStyle"><%#Eval("ContractorNumber")%></td>
<td class="RowStyle"><%#Eval("FirstName")%></td>
<td class="RowStyle"><%#Eval("LastName")%></td>
<td class="RowStyle">
<asp:HyperLink ID="lnkView" runat="server" CssClass="link"
NavigateUrl='<%# "ContractorEdit.aspx?ID=" + Eval("ContractorNumber") + "&Mode=" + "CV" %>'
Target="_blank" Text="View" />
</td>
<td class="RowStyle">
<asp:HyperLink ID="lnkEdit" runat="server" CssClass="link"
NavigateUrl= '<%# "ContractorEdit.aspx?ID=" + Eval("ContractorNumber") + "&Mode=" + "CE" %>'
Text="Edit"> </asp:HyperLink>
</tr>
</div>
</ItemTemplate>
<AlternatingItemTemplate>
<div>
<tr>
<td class="AlternatingRowStyle"><%#Eval("ContractorNumber")%></td>
<td class="AlternatingRowStyle"><%#Eval("FirstName")%></td>
<td class="AlternatingRowStyle"><%#Eval("LastName")%></td>
<td class="AlternatingRowStyle">
<asp:HyperLink ID="lnkView" runat="server" CssClass="link"
NavigateUrl='<%# "Contractor.aspx?ID=" + Eval("ContractorNumber")%>'
Target="_blank" Text="View" />
</td>
<td class="AlternatingRowStyle">
<asp:HyperLink ID="lnkEdit" runat="server" CssClass="link"
NavigateUrl= '<%# "ContractorEdit.aspx?ID=" + Eval("ContractorNumber") + "&Mode=" + "CE" %>'
Text="Edit"> </asp:HyperLink>
</tr>
</div>
</AlternatingItemTemplate>
<ItemSeparatorTemplate>
<tr>
<td colspan="5" class="itemseparator"></td>
</tr>
</ItemSeparatorTemplate>
</asp:ListView>
<div class="pager">
<asp:DataPager PageSize="20" ID="DataPagerContractor" runat="server" PagedControlID="lvContractors"
NextPreviousButtonCssClass="PrevNext"
CurrentPageLabelCssClass="CurrentPage"
NumericButtonCssClass="PageNumber">
<fields>
<asp:NumericPagerField
PreviousPageText="< Prev"
NextPageText="Next >"
ButtonCount="10"
NextPreviousButtonCssClass="PrevNext"
CurrentPageLabelCssClass="CurrentPage"
NumericButtonCssClass="PageNumber" />
</fields>
</asp:DataPager>
</div>
</div> Code behind this: Partial Class Contractor
Inherits System.Web.UI.Page
Private txtKeywordSearchWhereClause As String = ""
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Session("Clicked") = "Contractor"
End If
If Not DBNull.Value.Equals(txtKeywordSearchWhereClause) Then
LoadContractors(txtKeywordSearchWhereClause)
Else
LoadContractors("")
End If
End Sub
Private Sub LoadContractors(ByVal strSearch As String)
Dim strConn As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("Conn").ConnectionString)
strConn.Open()
Dim sql As String = "SELECT * FROM tblContractor1"
If Not strSearch = "" Then
sql = sql & strSearch
sql = sql & " ORDER BY LastName"
End If
Dim da As SqlDataAdapter = New SqlDataAdapter(sql, strConn)
Dim dt As DataTable = New DataTable()
da.Fill(dt)
lvContractors.DataSource = dt
lvContractors.DataBind()
End Sub
Protected Sub buttonAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles buttonAdd.Click
Response.Redirect("ContractorEdit.aspx", False)
End Sub
Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
' Keyword Search
Dim txtKeywordSearch As String = txtSearch.Text
Dim txtWhereClause As String = ""
If txtKeywordSearch.Trim() <> "" Then
txtWhereClause = " WHERE FirstName LIKE '%" + txtKeywordSearch + "%'"
txtWhereClause = txtWhereClause + " OR LastName LIKE '%" + txtKeywordSearch + "%'"
txtWhereClause = txtWhereClause + " OR ContractorNumber LIKE '%" + txtKeywordSearch + "%'"
txtKeywordSearchWhereClause = txtWhereClause
End If
LoadContractors(txtKeywordSearchWhereClause)
End Sub
Protected Sub lvContractors_PagePropertiesChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.PagePropertiesChangingEventArgs) Handles lvContractors.PagePropertiesChanging
DataPagerContractor.SetPageProperties(e.StartRowIndex, e.MaximumRows, False)
'rebind List View
If Not DBNull.Value.Equals(txtKeywordSearchWhereClause) Then
LoadContractors(txtKeywordSearchWhereClause)
Else
LoadContractors("")
End If
End Sub
End Class
|
|
|
|
|
hi all,
Ajax calendar extender not working in .Please suggest me better way to show calendar in black berry phone.
Regards,
Vishnu.
|
|
|
|
|
hi friends
i need to create a mergetag which combines the fields which i specifiy instead of the email if of the person
so how to use the mergetag...
can anyone help me with an example..
K.Gayathri
|
|
|
|
|
Hello everyone,
Im having a problem regarding in adding item in a listbox
when im invoking a delegate. this code is in an ascx file.
this is my codes:
Public Delegate Sub addLstBoxDel(ByVal fileFound As String)
Public Sub addLstBox(ByVal fileFound As String)
lstResult.Items.Add(fileFound)
End Sub
Dim ALBDelegate As me.addLstBoxDel
ALBDelegate = AddressOf Me.addLstBox
ALBDelegate.Invoke(file)
Thanks in advance,
jyn
|
|
|
|
|
init the delegate using 'New'
|
|
|
|
|
Barbo,
Thanks to your reply. I already add New but still listbox is not updated.
i put the init of delegate on page.init and page.load but still no luck.
i so added postback=true on listbox.
Thanks again,
jyn
|
|
|
|
|
Error:
Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive.
|
|
|
|
|
|
Is it possible,To remove session when user close his browser.
if yes , how?
|
|
|
|
|
|
It is for restoring Session not for deleting.
|
|
|
|
|
try this:
1. First create a page LogOut.aspx and in Page_Load event write this code:-
protected void Page_Load(object sender, EventArgs e)
{
Session.Abandon();
}
2. Then add following JavaScript code in your page or Master Page:-
<script type="text/javascript">
var clicked = false;
function CheckBrowser()
{
if (clicked == false)
{
}
else
{
clicked = false;
}
}
function bodyUnload()
{
if (clicked == false)
{
var request = GetRequest();
request.open ("GET", "AutoLogOut.aspx", true);
request.send();
}
}
function GetRequest()
{
var request = null;
if (window.XMLHttpRequest)
{
request = new XMLHttpRequest();
}
else
{
request = new ActiveXObject('MSXML2.XMLHTTP.3.0');
}
return request;
}
3. Add the following code in the body tag of master page.
<body onunload="bodyUnload();" Onclick="clicked=true;">
Finally the code in Master page like this:-
<script language="javascript" type="text/javascript">
var clicked = false;
function CheckBrowser() {
if (clicked == false) {
}
else {
clicked = false;
}
}
function bodyUnload() {
if (clicked == false)
{
var request = GetRequest();
request.open("GET", "LogOut.aspx", true);
request.send();
}
}
function GetRequest() {
var request = null;
if (window.XMLHttpRequest) {
request = new XMLHttpRequest();
}
else {
request = new ActiveXObject('MSXML2.XMLHTTP.3.0');
}
return request;
}
</script>
<body onunload="bodyUnload();" onclick="clicked=true;">
<form id="form1" runat="server">
|
|
|
|
|
hiiiiiiii to all
how we can maintain old data in gridgiew after updating the the particular.......
any one can tell.
Thanks in advance
rizvan sivally
|
|
|
|
|
I Used Update Command as for this
Update tblJobs set [Status]=Status+ ' * ' + @Status +' ' +Cast(getdate() as varchar(50))+' <br/> ',Remarks=Remarks+ ' * ' + @Remarks + ''+Cast(getdate() as varchar(50))+ ' <br/> 'where Id=@Id"
see Remarks=Remarks+ ' * ' + @Remarks this update Remarks Column and your previous data remains same.
|
|
|
|
|
hello,
Sir/Madam
I want to create a mail website like gmail in asp.net using c#,i am confused how to start it? Can u suggest me how i can start and give me some ideas abt it.
|
|
|
|
|
You start by studying and doing the research necessary to give you the understanding so you will know where to start. In any case, there are numerous tutorials here and via Google that would help if you can be bothered to do your own work.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
nils illegitimus carborundum
me, me, me
|
|
|
|
|
I have Master Page.
i insert jquery to head tag like this but I think that page can't load jquery_min.js file. How can i slove this?
(Below is master page)
<head runat="server">
<script type="text/javascript" src="common/scripts/jquery_min.js"></script>
I want to load Jquery script when page load
Because I have to use below code.
(Below is master page)
<script type="text/javascript">
$(document).ready(function () {
$.get('../common/path.xml', function (data)...........
});
hi
My english is a little.
anyway, nice to meet you~~
and give me your advice anytime~
|
|
|
|
|
Not entirely sure what your problem is. You can certainly reference the jquery script file in your master page and, in fact, should do so. What error are you getting? Perhaps the path to the script is incorrect.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
nils illegitimus carborundum
me, me, me
|
|
|
|
|
Hi,
I am developing an Android Application where I would like to submit a search string to an ASP.NET web page. The App would then format the returned data. Any tips on how I might accomplish this?
Thank you!
|
|
|
|
|
Can any one help me to understand the concept of global.asax file in asp.net3.5
Thanks and regards
|
|
|
|
|
|
Thanks for the suggestion
|
|
|
|
|
Actually you should bookmark -> google.com[^]
Apurv
If Java had true garbage collection, most programs would delete themselves upon execution.
|
|
|
|
|
hi friends
i need to send mails from an asp.net application using c# but my IIS is not configured in my laptop so how to send mails
can anyone help me in this issue plz..
K.Gayathri
|
|
|
|
|
You don't need to configure IIS. The SmtpMail[^] class has a static property used to set the SMTP server to send mail through. You can also configure this in the web.config file in the mailSettings[^] element
No comment
|
|
|
|