Search on the basis of dropdown values - c#

I have a dropdown in which I have two options,
a. Selected
b. Not Selected.
I want whenever the user selects any option, the search should filter on that basis. I have a column of Selection in gridview which has both option Selected and Not Selected. The values are coming from the table.
Please see the HTML of dropdown and button for your reference:
<div style="float: left;">
<asp:DropDownList ID="ddlSort" runat="server" AutoPostBack="false" OnSelectedIndexChanged="ddlSort_SelectedIndexChanged">
<asp:ListItem Text="--Select--" Value="1"></asp:ListItem>
<asp:ListItem Text="Selected" Value="2"></asp:ListItem>
<asp:ListItem Text="Not Selected" Value="3"></asp:ListItem>
</asp:DropDownList>
<asp:Button ID="btnSortSelection" runat="server" Text="Sort Selection" OnClick="btnSortSelection_Click" />
</div>
I tried with the below mentioned code but the page refreshes and the dropdown inside the gridview loses its value. So it did not returns my search result.:-
protected void ddlSort_SelectedIndexChanged(object sender, EventArgs e) {
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultSQLConnectionString"].ConnectionString); //create connection
SqlCommand cmd = new SqlCommand("Select * from Career.Applicant where Selection =#Selected", conn);
cmd.Parameters.AddWithValue("#selection", ddlSort.SelectedValue);
}
I want to stop the dropdownlist values to get postback and also it should work when sorted
Please see the code with Updated Panel:-
<asp:UpdatePanel runat="server" ID="updateapplicants">
<ContentTemplate>
<div style="border: 1px solid #A8A8A8; width: 920px;">
<asp:GridView ID="gv_Applicants" runat="server" AutoGenerateColumns="false" AllowPaging="true" Width="920"
PageSize="5" OnPageIndexChanging="gv_Applicants_PageIndexChanging" OnRowCommand="gv_Applicants_RowCommand"
EmptyDataText="No Applicants Found."
AllowSorting="true"
OnSorting="gv_Applicants_Sorting"
OnRowDataBound="gv_Applicants_RowDataBound" RowStyle-CssClass="a12" AlternatingRowStyle-CssClass="a22" ForeColor="#333333" GridLines="None" CssClass="table_box" HeaderStyle-Height="35px" DataKeyNames="JobId">
<AlternatingRowStyle BackColor="#F0F0F0" />
<Columns>
<asp:BoundField DataField="FirstName" HeaderText="First Name" HeaderStyle-Width="84" />
<asp:BoundField DataField="LastName" HeaderText="Last Name" HeaderStyle-Width="106" />
<asp:BoundField DataField="ContactNumber" HeaderText="Contact" HeaderStyle-Width="98" />
<asp:BoundField DataField="Email" HeaderText="Email" HeaderStyle-Width="150" />
<asp:TemplateField HeaderText="Position" SortExpression="Position" HeaderStyle-Width="107">
<ItemTemplate>
<%# Eval("Job.Position") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Location" SortExpression="Location" HeaderStyle-Width="100">
<ItemTemplate>
<%# Eval("Job.Location") %>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="AppliedDate" DataFormatString="{0:MMMM dd, yyyy}" HeaderText="Date of Application" ReadOnly="true" HeaderStyle-Width="121" />
<asp:TemplateField HeaderText="Action" HeaderStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:LinkButton ID='lnkView' CommandName='v' Text='View' runat='server' CommandArgument='<%# Eval("ApplicantId") %>'></asp:LinkButton>
|
<asp:LinkButton ID='lnkdel' CommandName='d' Text='Delete' runat='server' CommandArgument='<%# Eval("ApplicantId") %>' OnClientClick="return confirm('Are you sure to delete?');"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Selection">
<ItemTemplate>
<asp:DropDownList ID="ddlSelection" runat="server" EnableViewState="true" AutoPostBack="true">
<asp:ListItem Text="None" Value="1"></asp:ListItem>
<asp:ListItem Text="Selected" Value="2"></asp:ListItem>
<asp:ListItem Text="Not Selected" Value="3"></asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="JobId" HeaderText="Job ID" Visible="false" ReadOnly="true" />
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#D8DADA" Font-Bold="True" />
<HeaderStyle BackColor="#D8DADA" Font-Bold="True" />
<PagerStyle BackColor="#D8DADA" HorizontalAlign="Center" />
<RowStyle BackColor="white" BorderStyle="Solid" BorderColor="#a8a8a8" BorderWidth="1px" Height="35" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
</asp:GridView>
</div>
<br />
<br />
<div id="divDetails" runat="server" class="force-overflow">
<div class="scrollbar" id="style-1">
<div style="border-left: 1px solid #A8A8A8; border-right: 1px solid #A8A8A8;">
<asp:DetailsView ID="dv_Applicants" HeaderStyle-Font-Bold="true" HeaderStyle-BackColor="#F7E1E1" runat="server" AutoGenerateRows="false" AllowPaging="false"
HeaderText="Applicant Details" OnDataBound="dv_Applicants_DataBound" Width="912px" BackColor="#F0F0F0" BorderStyle="Solid" BorderWidth="1" BorderColor="#F0F0F0"
RowStyle-Height="30" Font-Size="10">
<Fields>
<asp:TemplateField HeaderText="Position" HeaderStyle-CssClass="c_width">
<ItemTemplate>
<%#Eval("Job.Position") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Location" HeaderStyle-CssClass="c_width">
<ItemTemplate>
<%#Eval("Job.Location") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Business Unit" HeaderStyle-CssClass="c_width">
<ItemTemplate>
<%#Eval("Job.BusinessUnit") %>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="FirstName" HeaderText="First Name" HeaderStyle-Width="190" HeaderStyle-Font-Bold="true" />
<asp:BoundField DataField="LastName" HeaderText="Last Name" HeaderStyle-Width="190" HeaderStyle-Font-Bold="true" />
<asp:BoundField DataField="ContactNumber" HeaderText="Contact" HeaderStyle-Width="190" HeaderStyle-Font-Bold="true" />
<asp:BoundField DataField="Email" HeaderText="Email" HeaderStyle-Width="190" HeaderStyle-Font-Bold="true" />
<asp:BoundField DataField="PAN" HeaderText="PAN" HeaderStyle-Width="190" HeaderStyle-Font-Bold="true" />
<asp:BoundField DataField="DOB" DataFormatString="{0:MMMM dd, yyyy}" HeaderText="Date of Birth" HeaderStyle-Width="190" HeaderStyle-Font-Bold="true" />
<asp:BoundField DataField="Graduation" HeaderText="Graduation" HeaderStyle-Width="190" HeaderStyle-Font-Bold="true" />
<asp:BoundField DataField="GradOther" HeaderText="Other" HeaderStyle-Width="190" HeaderStyle-Font-Bold="true" />
<asp:BoundField DataField="GradDate" DataFormatString="{0:MMMM dd, yyyy}" HeaderText="Graduation Date" HeaderStyle-Width="190" HeaderStyle-Font-Bold="true" />
<asp:BoundField DataField="PostGraduation" HeaderText="Post Graduation" HeaderStyle-Width="190" HeaderStyle-Font-Bold="true" />
<asp:BoundField DataField="PGOther" HeaderText="Other" HeaderStyle-Width="190" HeaderStyle-Font-Bold="true" />
<asp:BoundField DataField="PGDate" DataFormatString="{0:MMMM dd, yyyy}" HeaderText="Post Graduation date" HeaderStyle-Width="190" HeaderStyle-Font-Bold="true" />
<asp:BoundField DataField="AnyOtherQual" HeaderText="Any Other Qualification" HeaderStyle-Width="190" HeaderStyle-Font-Bold="true" />
<asp:BoundField DataField="CurrentOrg" HeaderText="Organization" HeaderStyle-Width="190" HeaderStyle-Font-Bold="true" />
<asp:BoundField DataField="CurrentDesignation" HeaderText="Designation" HeaderStyle-Width="190" HeaderStyle-Font-Bold="true" />
<asp:BoundField DataField="CurrentFunctionalDesig" HeaderText="Current Functional Designation" HeaderStyle-Width="190" HeaderStyle-Font-Bold="true" />
<asp:BoundField DataField="CurrentCTC" DataFormatString="{0} lakhs per annum" HeaderText="CTC" HeaderStyle-Width="190" HeaderStyle-Font-Bold="true" />
<asp:BoundField DataField="YrsinCurrentRole" HeaderText="Current Experience" HeaderStyle-Width="190" HeaderStyle-Font-Bold="true" />
<asp:BoundField DataField="TotalExp" HeaderText="Total Experience" HeaderStyle-Width="190" HeaderStyle-Font-Bold="true" />
<asp:BoundField DataField="KeySkills" HeaderText="Skills" HeaderStyle-Width="190" HeaderStyle-Font-Bold="true" />
<asp:BoundField DataField="City" HeaderText="City" HeaderStyle-Width="190" HeaderStyle-Font-Bold="true" />
<asp:BoundField DataField="State" HeaderText="State" HeaderStyle-Width="190" HeaderStyle-Font-Bold="true" />
<asp:BoundField DataField="Country" HeaderText="Country" HeaderStyle-Width="190" HeaderStyle-Font-Bold="true" />
<asp:TemplateField HeaderText="Willing to Relocate" ControlStyle-CssClass="c_width" HeaderStyle-CssClass="c_width">
<ItemTemplate>
<%# Convert.ToBoolean(Eval("WillingtoRelocate")) == true ? "Yes" : "No" %>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="LocationPreference" HeaderText="Location Preference" HeaderStyle-Width="190" HeaderStyle-Font-Bold="true" />
<asp:BoundField DataField="AppliedDate" DataFormatString="{0:MMMM dd, yyyy}" HeaderText="Date of Application" ReadOnly="true" HeaderStyle-Font-Bold="true" />
<asp:HyperLinkField DataNavigateUrlFields="CVFilePath" Text="View Resume" ControlStyle-ForeColor="White" ControlStyle-CssClass="bg" Target="_blank" />
</Fields>
</asp:DetailsView>
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>

Related

Create Searchbox after generating Gridview Data

I have my GridView here .. (Automatically generated as WebForm Template)
I want to create a searchbox wherein I can search all the PTAID ..
Here's my codes
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" ShowFooter="True" OnRowCommand="grdSearch_RowCommand" CssClass="table table-bordered table-hovered">
<Columns>
<asp:TemplateField >
<FooterTemplate>
<asp:TextBox ID="text_search" runat="server" CssClass="form-control" />
<asp:Button ID="btnSearch" CommandName="Search" runat="server" Text="Search" />
</FooterTemplate>
</asp:TemplateField>
<asp:BoundField DataField="PTAID" HeaderText="PTAID" SortExpression="PTAID" />
<asp:BoundField DataField="RequestID" HeaderText="RequestID" SortExpression="RequestID" />
<asp:BoundField DataField="RequestDate" HeaderText="RequestDate" SortExpression="RequestDate" />
<asp:BoundField DataField="ProvName" HeaderText="ProvName" SortExpression="ProvName" />
<asp:BoundField DataField="Amount" HeaderText="Amount" SortExpression="Amount" />
<asp:BoundField DataField="INorOUT" HeaderText="INorOUT" SortExpression="INorOUT" />
<asp:BoundField DataField="Supplier" HeaderText="Supplier" SortExpression="Supplier" />
<asp:BoundField DataField="Customer" HeaderText="Customer" SortExpression="Customer" />
<asp:BoundField DataField="Program" HeaderText="Program" SortExpression="Program" />
<asp:BoundField DataField="IssueDesc" HeaderText="IssueDesc" SortExpression="IssueDesc" />
<asp:BoundField DataField="Chargeable" HeaderText="Chargeable" SortExpression="Chargeable" />
<asp:BoundField DataField="Company" HeaderText="Company" SortExpression="Company" />
</Columns>
</asp:GridView>
How will I make a searchbox ? I tried the one I searched but then i wanted to show the GridView data and the searchbox altogether.
Please try following code, it should work:
<div>
Enter UserName :
<asp:TextBox ID="txtSearch" runat="server" />
<asp:ImageButton ID="btnSearch" text="Search" runat="server"
Style="top: 5px; position: relative; width: 26px;" />
<asp:ImageButton ID="btnClear" text="Clear" runat="server" Style="top: 5px;
position: relative; width: 14px;" /><br />
<br />
</p>
<asp:GridView ID="gvDetails" runat="server" AutoGenerateColumns="False" AllowPaging="True"
AllowSorting="True" DataSourceID="dsDetails" Width="540px" CssClass="Gridview" >
<HeaderStyle BackColor="#df5015" />
<Columns>
<asp:BoundField DataField="PTAID" HeaderText="PTAID" SortExpression="PTAID" />
<asp:BoundField DataField="RequestID" HeaderText="RequestID" SortExpression="RequestID" />
<asp:BoundField DataField="RequestDate" HeaderText="RequestDate" SortExpression="RequestDate" />
<asp:BoundField DataField="ProvName" HeaderText="ProvName" SortExpression="ProvName" />
<asp:BoundField DataField="Amount" HeaderText="Amount" SortExpression="Amount" />
<asp:BoundField DataField="INorOUT" HeaderText="INorOUT" SortExpression="INorOUT" />
<asp:BoundField DataField="Supplier" HeaderText="Supplier" SortExpression="Supplier" />
<asp:BoundField DataField="Customer" HeaderText="Customer" SortExpression="Customer" />
<asp:BoundField DataField="Program" HeaderText="Program" SortExpression="Program" />
<asp:BoundField DataField="IssueDesc" HeaderText="IssueDesc" SortExpression="IssueDesc" />
<asp:BoundField DataField="Chargeable" HeaderText="Chargeable" SortExpression="Chargeable" />
<asp:BoundField DataField="Company" HeaderText="Company" SortExpression="Company" />
</Columns>
</asp:GridView>
</div>
<asp:SqlDataSource ID="dsDetails" runat="server" ConnectionString="<%$ ConnectionStrings:DemoConnectionString %>" SelectCommand="SELECT [name], [address] FROM [stud_info]" FilterExpression="Name LIKE '%{0}%'">
<FilterParameters>
<asp:ControlParameter Name="PTAID" ControlID="txtSearch" PropertyName="Text" />
</FilterParameters>
</asp:SqlDataSource>

Delete query produces two different errors

I have a couple of gridviews in my website. Here's the code:
changeSlides.aspx:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="ID" DataSourceID="AccessDataSource1">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False"
ReadOnly="True" SortExpression="ID" />
<asp:ImageField DataImageUrlField="picPath"
DataImageUrlFormatString="PlaceImages/{0}" HeaderText="Picture" ControlStyle-CssClass="editPhotoGridFormat">
<ControlStyle CssClass="editPhotoGridFormat"></ControlStyle>
</asp:ImageField>
<asp:BoundField DataField="PicPath" HeaderText="Filename" />
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
<asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
<asp:BoundField DataField="Country" HeaderText="Country"
SortExpression="Country" />
</Columns>
</asp:GridView>
EditBlogPost.aspx:
<asp:GridView ID="GridView1" runat="server" AllowSorting="True"
AutoGenerateEditButton="True"
DataSourceID="AccessDataSource1"
AutoGenerateColumns="False" DataKeyNames="ID"
AlternatingRowStyle-BackColor="Gray"
AlternatingRowStyle-CssClass="editGridFormat" RowStyle-CssClass="editGridFormat"
RowStyle-VerticalAlign="Top"
onselectedindexchanged="GridView1_SelectedIndexChanged">
<AlternatingRowStyle BackColor="Gray" CssClass="editGridFormat"></AlternatingRowStyle>
<Columns>
<asp:CommandField ShowSelectButton="True" ShowDeleteButton="True" />
<asp:BoundField DataField="ID" HeaderText="ID" />
<asp:BoundField DataField="BlogTitle" HeaderText="BlogTitle"
SortExpression="BlogTitle" />
<asp:ImageField DataImageUrlField="Image" HeaderText="Image"
DataImageUrlFormatString="~/PlaceImages/{0}" ControlStyle-CssClass="editPhotoGridFormat"
AlternateText="Either a wrong file type or a misspelled file name has occurred"
NullDisplayText="No picture on file" >
<ControlStyle CssClass="editPhotoGridFormat"></ControlStyle>
</asp:ImageField>
<asp:BoundField DataField="Caption"
HeaderText="Caption for Picture on Homepage" />
<asp:TemplateField headertext="Text for the homepage">
<EditItemTemplate>
<asp:TextBox id="PicTextBox" runat="server" text='<%# Bind("PicText")%>' textmode="MultiLine" height="300px" width="300px" />
</EditItemTemplate>
<ItemTemplate>
<%# Eval("PicText")%>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="TravelDate" HeaderText="Date of Travel"
SortExpression="TravelDate" DataFormatString="{0:MMMMMMMMM, dd, yyyy }" HtmlEncode="false" />
<asp:TemplateField headertext="Top of the Blog Post">
<EditItemTemplate>
<asp:TextBox id="BeginTextBox" runat="server" text='<%# Bind("BeginText")%>' textmode="MultiLine" height="300px" width="300px" />
</EditItemTemplate>
<ItemTemplate>
<%# Eval("BeginText")%>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="City" HeaderText="City" />
<asp:BoundField DataField="Country" HeaderText="Country"
SortExpression="Country" />
<asp:TemplateField headertext="Text at the End of the Post">
<EditItemTemplate>
<asp:TextBox id="EndTextBox" runat="server" text='<%# Bind("EndText")%>' textmode="MultiLine" height="300px" width="300px" />
</EditItemTemplate>
<ItemTemplate>
<%# Eval("EndText")%>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle VerticalAlign="Top" CssClass="editGridFormat"></RowStyle>
</asp:GridView>
EditPeoplePhotos.aspx:
<asp:GridView ID="GridView1" runat="server" AllowSorting="True"
DataSourceID="AccessDataSource1" Width="493px">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True"
ShowSelectButton="True" />
<asp:ImageField DataImageUrlField="picPath"
DataImageUrlFormatString="photos/PeoplePhotos/{0}" HeaderText="Picture" ControlStyle-CssClass="editPhotoGridFormat">
</asp:ImageField>
</Columns>
</asp:GridView>
My update statements work, but my delete statements don't work in two of the three gridviews. My corresponding delete statements are all virtually the same: "DELETE FROM (Table Name) WHERE ID=?" but I get different error codes, which are as follows:
For changeSlides.aspx, it says "Entry with same key already exists"
For EditBlogPosts.aspx, it work fine. It deletes the blog.
For EditPeoplePhotos.aspx, it says "No value given for one or more required parameters"
Each of those pages use a separate, unrelated table in my database, and each query is only referring to one table, so there are no foreign keys used.
What is going on?

How to show sum of values on header text in grid view?

I want to show sum of values on header text in grid view.
Code:
.aspx
<asp:GridView ID="gvTrHty" runat="server" AutoGenerateColumns="false" Width="100%"
Style="border: 0px solid #cdcdcd; background-color: #cdcdcd;" border="0" CellSpacing="1"
CellPadding="3" OnSorting="gvTrHty_Sorting" AllowSorting="true">
<Columns>
<asp:TemplateField HeaderText="S.No" ItemStyle-VerticalAlign="Middle" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<%#Container.DataItemIndex+1 %>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="Employee" DataField="UserFullName" SortExpression="UserFullName" />
<asp:BoundField HeaderText="Course" DataField="CourseName" SortExpression="CourseName" />
<asp:BoundField HeaderText="Duration(Hrs)" DataField="Duration" SortExpression="Duration" />
<asp:BoundField HeaderText="Start Date" DataField="StartDate" DataFormatString="{0:dd-MMM-yyyy}"
SortExpression="StartDate" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle" />
<asp:BoundField HeaderText="End Date" DataField="EndDate" DataFormatString="{0:dd-MMM-yyyy}"
SortExpression="EndDate" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle" />
<asp:BoundField HeaderText="Result" DataField="RESULT" ItemStyle-HorizontalAlign="Center"
SortExpression="RESULT" ItemStyle-VerticalAlign="Middle" />
<asp:BoundField HeaderText="Year" DataField="Year" ItemStyle-HorizontalAlign="Center"
SortExpression="Year" ItemStyle-VerticalAlign="Middle" />
<asp:BoundField HeaderText="Category" DataField="Category" ItemStyle-HorizontalAlign="Center"
SortExpression="Category" ItemStyle-VerticalAlign="Middle" />
<asp:BoundField HeaderText="Sub Category" DataField="SubCategory" SortExpression="SubCategory" />
</Columns>
<HeaderStyle CssClass="header-link grid-Header DataGridFixedHeader gvHead " />
<RowStyle CssClass="gd_odd_txt gvRow" />
</asp:GridView>
In the below image format I want to get sum of Duration
Any ideas? Thanks in advance

A lot of problems with IE 9, datagrid, TabContainer, etc

I'm having several problems with IE 9, so the first is the DataGrid Button column is not firing and in Chrome works ok, then the TabContainer is not displaying at all, also in chrome does, what could it be?
<tr>
<td>
<asp:DataGrid ID="dgOficios2" runat="server"
AutoGenerateColumns="False" AllowSorting="True"
ondeletecommand="dgOficios2_DeleteCommand"
oneditcommand="dgOficios2_EditCommand"
OnSortCommand="dgOficios2_SortCommand"
OnItemDataBound="dgOficios_Bound" >
<EditItemStyle BackColor="#CCCCCC" />
<AlternatingItemStyle BackColor="#C1D0EC" />
<HeaderStyle BackColor="#0B63A2" ForeColor="White" />
<Columns>
<asp:EditCommandColumn CancelText="Cancel" EditText="Editar" UpdateText="Update" Visible="false">
<ItemStyle Wrap="False" />
<HeaderStyle Wrap="False" />
</asp:EditCommandColumn>
<asp:ButtonColumn CommandName="Delete" Text="Distribuir"></asp:ButtonColumn>
<asp:BoundColumn DataField="Id" HeaderText="Id" SortExpression="Id"
Visible="False"></asp:BoundColumn>
<asp:BoundColumn DataField="TypeCCompany" HeaderText="Bloque" SortExpression="TypeCCompany"
Visible="false"></asp:BoundColumn>
<asp:BoundColumn DataField="DocNum" HeaderText="NĂºmero Oficio" SortExpression="DocNum"
Visible="true"></asp:BoundColumn>
<asp:BoundColumn DataField="Receiver" HeaderText="Destino" SortExpression="Receiver"
Visible="false"></asp:BoundColumn>
<asp:BoundColumn DataField="SigantureDoc" HeaderText="Firma" SortExpression="SigantureDoc"
Visible="false"></asp:BoundColumn>
<asp:BoundColumn DataField="SignaturePosition" HeaderText="Puesto" SortExpression="SignaturePosition"
Visible="false"></asp:BoundColumn>
<asp:BoundColumn DataField="Status" HeaderText="Estatus" SortExpression="Status"
Visible="false"></asp:BoundColumn>
<asp:BoundColumn DataField="Note" HeaderText="Asunto" SortExpression="Note"
Visible="true"></asp:BoundColumn>
<asp:BoundColumn DataField="Date" HeaderText="Fecha" SortExpression="Date"
Visible="true"></asp:BoundColumn>
<asp:BoundColumn DataField="ReceiverDate" HeaderText="Fecha de Recepcion" SortExpression="ReceiverDate"
Visible="false"></asp:BoundColumn>
<asp:BoundColumn DataField="ModificationDate" HeaderText="Fecha de Modificacion" SortExpression="ModificationDate"
Visible="false"></asp:BoundColumn>
<asp:BoundColumn DataField="CreationDate" HeaderText="Fecha de Creacion" SortExpression="CreationDate"
Visible="false"></asp:BoundColumn>
<asp:BoundColumn DataField="TypeCDocument" HeaderText="TypeCDocument" SortExpression="TypeCDocument"
Visible="false"></asp:BoundColumn>
<asp:BoundColumn DataField="Prior" HeaderText="Antecedentes" SortExpression="Prior"
Visible="false"></asp:BoundColumn>
<asp:BoundColumn DataField="Consecutive" HeaderText="Consecutivo" SortExpression="Consecutive"
Visible="false"></asp:BoundColumn>
<asp:BoundColumn DataField="Letter" HeaderText="Letra" SortExpression="Letter"
Visible="false"></asp:BoundColumn>
<asp:BoundColumn DataField="InputOutput" HeaderText="Entrada/Salida" SortExpression="InputOutput"
Visible="false"></asp:BoundColumn>
<asp:BoundColumn DataField="RemainderDate" HeaderText="Recordatorio" SortExpression="RemainderDate"
Visible="false"></asp:BoundColumn>
</Columns>
</asp:DataGrid>
</td>
</tr>
And the TabContainer:
<asp:Content ID="sist" runat="server" ContentPlaceHolderID="formas">
<cc1:TabContainer ID="tbSist" runat="server" ActiveTabIndex="1" >
<cc1:TabPanel ID="tblDestinos" runat="server">
<HeaderTemplate>Personas de Atencion</HeaderTemplate>
<ContentTemplate >
<asp:MultiView ID="mview1" runat="server" ActiveViewIndex="0">
<asp:View runat="server">
<table>
<tr>
<td>
<asp:LinkButton ID="ButtonUsuariosNew2" runat="server" OnClick="ButtonUsuariosNew_Click" Text="Agregar Nuevo"/>
</td>
</tr>
This is driving me insane is done in asp.net, it works in development in both IE6 and IE9, wth microsoft, is in iis7. The cc1 is an AjaxControlToolkit, help?. Thanks
Edit: Yes I have another Datagrid with buttons only this one does work.
<asp:DataGrid ID="dgUsuarios" runat="server"
AutoGenerateColumns="False" AllowSorting="True"
ondeletecommand="dgUsuarios_DeleteCommand"
oneditcommand="dgUsuarios_EditCommand"
OnSortCommand="dgUsuarios_SortCommand"
ShowFooter="true" OnItemCommand="doInsert" AllowPaging="true" PageSize="50"
OnPageIndexChanged="pagechange">
<EditItemStyle BackColor="#CCCCCC" />
<AlternatingItemStyle BackColor="#C1D0EC" />
<HeaderStyle BackColor="#0B63A2" ForeColor="White" />
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:ImageButton ID="edit" CommandName="Edit" ImageUrl="~/img/editUser.png" Width="16px" Height="16px" runat="server" CausesValidation="false" ToolTip="Editar Usuarios" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:ImageButton ID="Delete" CommandName="Delete" ToolTip="Eliminar" runat="server" ImageUrl="~/img/deleteUser.png" Height="16px" Width="16px" CausesValidation="false" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="Id" HeaderText="Id" SortExpression="Id"
Visible="False"></asp:BoundColumn>
<asp:BoundColumn DataField="Name" HeaderText="Usuario" SortExpression="Name"
Visible="true"></asp:BoundColumn>
<asp:BoundColumn DataField="FullName" HeaderText="Nombre" SortExpression="FullName" Visible="false"
></asp:BoundColumn>
<asp:BoundColumn DataField="Position" HeaderText="Puesto" SortExpression="Position" Visible="false"
></asp:BoundColumn>
<asp:BoundColumn DataField="Email" HeaderText="Email" SortExpression="Email" Visible="false"
></asp:BoundColumn>
<asp:BoundColumn DataField="TypeCDoc" HeaderText="Area" SortExpression="TypeCDoc"
Visible="true">
</asp:BoundColumn>
<asp:BoundColumn DataField="Autorizar" HeaderText="Autoriza" SortExpression="Autorizar"
Visible="true">
</asp:BoundColumn>
<asp:BoundColumn DataField="Distribuir" HeaderText="Distribuye" SortExpression="Distribuir"
Visible="true">
</asp:BoundColumn>
<asp:BoundColumn DataField="Generar" HeaderText="Genera" SortExpression="Generar"
Visible="true">
</asp:BoundColumn>
<asp:BoundColumn DataField="Escanear" HeaderText="Escanea" SortExpression="Escanear"
Visible="true">
</asp:BoundColumn>
<asp:BoundColumn DataField="LeerTodo" HeaderText="Lee Todo" SortExpression="LeerTodo"
Visible="true">
</asp:BoundColumn>
<asp:BoundColumn DataField="Password" HeaderText="Password" SortExpression="Password"
Visible="false">
</asp:BoundColumn>
<asp:BoundColumn DataField="Enviar" HeaderText="Enviar" SortExpression="Enviar"
Visible="true">
</asp:BoundColumn>
<%--<asp:TemplateColumn >--%>
<%-- <ItemTemplate>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="ls" runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateColumn>--%>
</Columns>
</asp:DataGrid>
Solved, it was a problem with the ie9 for security all javascript was disable, so the events were not firing.

Displaying the record in an unfiltered GridView

I have a GridView control which displays records depending on the user input in a search textbox, I also have DropDownList to filter search. What I want to do is to display all the records from a table if a user doesnt type any input from the textbox. I've tried putting another table inside the EmptyDataTemplate but it looked a bit cramped. Is there another way?
<td>
Book Reservation<br />
<br />
Search for book title
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="categoryDataSource" DataTextField="name"
DataValueField="categoryid" AppendDataBoundItems="true" >
<asp:ListItem Value="-1" Selected="True">-- Choose a category --</asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="categoryDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:LibrarySystemConnectionString %>"
SelectCommand="SELECT [categoryid], [name] FROM [TblCategory]">
</asp:SqlDataSource>
<asp:Button ID="Button1" runat="server" Text="Search" />
<br />
<br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="bookid" DataSourceID="bookDataSource" Width="800px" AllowPaging="true"
AllowSorting="true" >
<Columns>
<asp:BoundField DataField="bookid" HeaderText="bookid" ReadOnly="True"
SortExpression="bookid" Visible="false" />
<asp:HyperLinkField DataTextField="booktitle" DataNavigateUrlFields="bookid" HeaderText="Title"
DataNavigateUrlFormatString="Reserving.aspx?bookid={0}" ItemStyle-Width="250px"
SortExpression="booktitle" />
<asp:BoundField DataField="booktitle" HeaderText="Title"
SortExpression="booktitle" Visible="false" />
<asp:BoundField DataField="lastname" HeaderText="Author"
SortExpression="lastname" />
<asp:BoundField DataField="firstname" HeaderText=""
SortExpression="firstname" />
<asp:BoundField DataField="description" HeaderText="Description"
SortExpression="description" />
<asp:BoundField DataField="categoryid" HeaderText="categoryid"
SortExpression="categoryid" Visible="false" />
<asp:BoundField DataField="name" HeaderText="Category"
SortExpression="name" />
<asp:BoundField DataField="dateadded" HeaderText="Dateadded"
SortExpression="dateadded" Visible="false" />
<asp:BoundField DataField="statusid" HeaderText="statusid"
SortExpression="statusid" Visible="false" />
<asp:BoundField DataField="quantity" HeaderText="Quantity"
SortExpression="quantity" />
</Columns>
<EmptyDataTemplate>
<span class="style2">Complete List</span>
<asp:GridView ID="GridView2" runat="server"
AutoGenerateColumns="False" AllowPaging="true" PageSize="8" AllowSorting="true"
DataKeyNames="bookid" DataSourceID="completebookDataSource" Width="800px">
<Columns>
<asp:BoundField DataField="bookid" HeaderText="bookid" ReadOnly="True"
SortExpression="bookid" Visible="false" />
<asp:HyperLinkField DataTextField="booktitle" DataNavigateUrlFields="bookid"
DataNavigateUrlFormatString="Reserving.aspx?bookid={0}" HeaderText="Title"
SortExpression="booktitle" ItemStyle-Width="250px" />
<%--<asp:BoundField DataField="booktitle" HeaderText="Title"
SortExpression="booktitle" />--%>
<asp:BoundField DataField="lastname" HeaderText="Author"
SortExpression="lastname" />
<asp:BoundField DataField="firstname" HeaderText=""
SortExpression="firstname" />
<asp:BoundField DataField="description" HeaderText="Description"
SortExpression="description" />
<asp:BoundField DataField="categoryid" HeaderText="categoryid"
SortExpression="categoryid" Visible="false" />
<asp:BoundField DataField="name" HeaderText="Category"
SortExpression="name" />
<asp:BoundField DataField="dateadded" HeaderText="dateadded"
SortExpression="dateadded" Visible="false" />
<asp:BoundField DataField="statusid" HeaderText="statusid"
SortExpression="statusid" Visible="false" />
<asp:BoundField DataField="quantity" HeaderText="Quantity"
SortExpression="quantity" />
<asp:CheckBoxField DataField="isdeleted" HeaderText="isdeleted"
SortExpression="isdeleted" Visible="false" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="completebookDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:LibrarySystemConnectionString %>"
SelectCommand="SELECT dbo.TblBooks.bookid, dbo.TblBooks.booktitle, dbo.TblBooks.lastname, dbo.TblBooks.firstname, dbo.TblBooks.description, dbo.TblBooks.categoryid, dbo.TblBooks.dateadded, dbo.TblBooks.statusid, dbo.TblBooks.quantity, dbo.TblBooks.isdeleted, dbo.TblCategory.name FROM dbo.TblBooks INNER JOIN dbo.TblCategory ON dbo.TblBooks.categoryid = dbo.TblCategory.categoryid ORDER BY dbo.TblBooks.booktitle ASC">
</asp:SqlDataSource>
</EmptyDataTemplate>
</asp:GridView>
<asp:SqlDataSource ID="bookDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:LibrarySystemConnectionString %>"
SelectCommand="SELECT dbo.TblBooks.bookid, dbo.TblBooks.booktitle, dbo.TblBooks.lastname, dbo.TblBooks.firstname, dbo.TblBooks.description, dbo.TblBooks.categoryid, dbo.TblBooks.dateadded, dbo.TblBooks.statusid, dbo.TblBooks.quantity, dbo.TblCategory.name FROM dbo.TblBooks INNER JOIN dbo.TblCategory ON dbo.TblBooks.categoryid = dbo.TblCategory.categoryid WHERE (dbo.TblBooks.categoryid = #categoryid) AND (dbo.TblBooks.booktitle LIKE '%' + #booktitle + '%')">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="categoryid"
PropertyName="SelectedValue" Type="Int32" />
<asp:ControlParameter ControlID="TextBox1" Name="booktitle" PropertyName="Text"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<br />
Help would be much appreciated.
Are you looking for this trick?
...WHERE (#Param1 IS NULL OR Field1 >= #Param1)
AND (#Param2 IS NULL OR Field2 LIKE '%' + #Param2 + '%')
You could also change the test to see if a param is equal to an empty string.

Categories

Resources