asp.net SQL RadioButton Columns - asp.net

<div class="grid">
<asp:GridView ID="gridView" CssClass="dataGrid" runat="server" SelectedRowStyle-BorderStyle="Double">
<Columns>
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:RadioButton ID="radioBtn" CssClass="radioBtn" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
RadioButton one elect want but all choose as you can see in picture

In order make only one radio button selectable on list of Radio Buttons you need to put them in a group like below:
<asp:RadioButton ID="RadioButton1" runat="server" Text="1454" GroupName="Group1" />
<br />
<asp:RadioButton ID="RadioButton2" runat="server" Text="1458" GroupName="Group1" />
<br />
<asp:RadioButton ID="RadioButton3" runat="server" Text="1545" GroupName="Group1" />
<br />
<asp:RadioButton ID="RadioButton4" runat="server" Text="1578" GroupName="Group1" />
<br />
<asp:RadioButton ID="RadioButton5" runat="server" Text="1965" GroupName="Group1" />
<br />
<asp:RadioButton ID="RadioButton5" runat="server" Text="3954" GroupName="Group1" />
<br />
<asp:RadioButton ID="RadioButton7" runat="server" Text="6543" GroupName="Group1" />
<br />
Once you group the radio button only one radio button in the group will be selectable.

Related

Exporting Excel is giving error on button click

I am implementing the functionality that on button click the data saved in the gridview should get exported on the button click, I implemented the functionality from here.
But I am getting error as Control 'mainContent_grdTeacherProfile' of type 'GridView' must be placed inside a form tag with runat=server at line
grdTeacherProfile.RenderControl(hw);
Please see the asps code of the gridview:-
<asp:GridView ID="grdTeacherProfile"
runat="server"
Width="100%"
border="1" Style="border: 1px solid #E5E5E5;"
CellPadding="3" FooterStyle-BackColor="#e3e3e3"
AutoGenerateColumns="false"
AllowPaging="true"
CssClass="hoverTable"
DataKeyNames="Id"
PageSize="4"
ShowFooter="false"
OnPreRender="PreRenderGrid"
HeaderStyle-CssClass="k-grid td"
OnDataBound="grdTeacherProfile_DataBound"
OnPageIndexChanging="grdTeacherProfile_PageIndexChanging"
OnRowDeleting="grdTeacherProfile_RowDeleting"
OnRowCommand="grdTeacherProfile_RowCommand"
EnableSortingAndPagingCallbacks="false"
EmptyDataText="No records found">
<AlternatingRowStyle CssClass="k-alt" />
<Columns>
<asp:TemplateField HeaderText="Select" ItemStyle-Width="5" >
<ItemTemplate>
<asp:CheckBox ID="chkDelete" runat="server" onClick="Check_Click(this)" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="first_name" HeaderText="First Name" ItemStyle-Width="30" />
<asp:BoundField DataField="last_name" HeaderText="Last Name" ItemStyle-Width="30" />
<asp:BoundField DataField="dob" HeaderText="Date of Birth" ItemStyle-Width="20" ApplyFormatInEditMode="true" DataFormatString="{0:d}" />
<asp:BoundField DataField="gender" HeaderText="Gender" ItemStyle-Width="20" />
<asp:BoundField DataField="designation" HeaderText="Designation" ItemStyle-Width="20" />
<asp:BoundField DataField="joining_date" HeaderText="Joining Date" ItemStyle-Width="20" ApplyFormatInEditMode="true" DataFormatString="{0:d}" />
<asp:BoundField DataField="leaving_date" HeaderText="Leaving Date" ItemStyle-Width="20" ApplyFormatInEditMode="true" DataFormatString="{0:d}" />
<asp:BoundField DataField="active" HeaderText="Active" ItemStyle-Width="25" />
<asp:TemplateField HeaderText="Action" HeaderStyle-Width="5%">
<ItemTemplate>
<asp:ImageButton ID="btnEdit" AlternateText="Edit" ImageUrl="~/images/edit.png" runat="server" Width="15" Height="15" CommandName="eEdit" CommandArgument='<%# Eval("Id") %>' CausesValidation="false" />
<asp:ImageButton ID="btnDelete" AlternateText="Delete" ImageUrl="~/images/delete.png" runat="server" Width="15" Height="15" CommandName="Delete" CommandArgument='<%# Eval("Id") %>' CausesValidation="false" OnClientClick="return confirm('Are you sure you want to delete this record?')" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle ForeColor="#e3e3e3"
BackColor="#e3e3e3" CssClass="grid-pagi" />
<PagerTemplate>
<table runat="server" id="testTable1" style="width: 100%" class="hoverTable_tbl">
<tr>
<td class="col-md-4 pull-left">
<asp:Label ID="MessageLabel"
Text="Select a page:"
runat="server" />
<asp:LinkButton ID="FirstLB" runat="server" CommandName="Page" CommandArgument="First" ToolTip="First" CssClass="btn-pager btn-default"><<</asp:LinkButton>
<asp:LinkButton ID="PrevLB" runat="server" CommandName="Page" CommandArgument="Prev" ToolTip="Previous" CssClass="btn-pager btn-default"><</asp:LinkButton>
<asp:DropDownList runat="server" ID="PageDropDownList" AutoPostBack="true" EnableViewState="true" OnSelectedIndexChanged="PageDropDownList_SelectedIndexChanged" CssClass="selectpicker form-control-drp"></asp:DropDownList>
<asp:LinkButton ID="NextLB" runat="server" CommandName="Page" CommandArgument="Next" ToolTip="Next" CssClass="btn-pager btn-default">></asp:LinkButton>
<asp:LinkButton ID="LastLB" runat="server" CommandName="Page" CommandArgument="Last" ToolTip="Last" CssClass="btn-pager btn-default">>></asp:LinkButton>
</td>
<td class="col-md-3">
<div>
<div class="pull-left"><asp:Label ID="PageSizeLabel" CssClass="page-size" runat="server" Text="Select Page Size: "></asp:Label>
<asp:DropDownList ID="ddlPageSize" runat="server" OnSelectedIndexChanged="ddlPageSize_SelectedIndexChanged" AutoPostBack="true" CssClass="selectpicker form-control-drp">
<%-- <asp:ListItem Value="0" Text="0" />--%>
<asp:ListItem Value="1" Text="1" />
<asp:ListItem Value="2" Text="2" />
<asp:ListItem Value="3" Text="3" />
</asp:DropDownList>
</div>
<div>
<asp:Label ID="CurrentPageLabel" CssClass="view" runat="server" />
</div>
</div>
</td>
</tr>
</table>
</PagerTemplate>
<RowStyle />
</asp:GridView>
Exporting GridView to Excel is easier using a 3rd party like iTextSharp.
If you want to know how I make it work, you can check this sample code:
http://dotnetfrommanila.blogspot.com/2013/04/convert-gridview-to-excel-in-c.html
I hope it could help you.
I got it done on my own,
actually I forgot to add the code below and EnableEventValidation="false".
The code was:-
public override void VerifyRenderingInServerForm(Control control)
{
/* Verifies that the control is rendered */
}
and it worked.!!

modal popup extender is not working in visual studio 2013 for web

I am encountering this issue:
asp.net ajax client-side framework failed to load
when I tried to open the modal popup-blocker.
How can I solve this? I've been struggling for weeks...
Here's the code for the same:
<form id="form1" runat="server">
<cc:ToolkitScriptManager ID="sc1" runat="server"></cc:ToolkitScriptManager>
<div>
<asp:Button ID="ModalCall" runat="server" OnClick="ModalCall_Click" Text="ModalCall" />
<cc:ModalPopupExtender ID="mod1" runat="server" CancelControlID="btn1" PopupControlID="pan1" TargetControlID="ModalCall"></cc:ModalPopupExtender>
<asp:Panel ID="pan1" runat="server">
<asp:Button ID="Register" runat="server" OnClick="Register_Click" Text="Register" />
<asp:TextBox ID="Email" runat="server"></asp:TextBox>
<asp:TextBox ID="Password" runat="server"></asp:TextBox>
<asp:TextBox ID="ConfirmPassword" runat="server"></asp:TextBox>
<br />
<asp:Button ID="Login" runat="server" OnClick="Login_Click" Text="Login" />
<asp:TextBox ID="LoginEmail" runat="server"></asp:TextBox>
<asp:TextBox ID="LoginPassword" runat="server"></asp:TextBox>
<br />
<asp:Button ID="CallService" runat="server" OnClick="CallService_Click" Text="Call Service" />
<br />
<asp:Button ID="ChangePassword" runat="server" OnClick="ChangePassword_Click" Text="ChangePassword" />
<asp:TextBox ID="OldPassword" runat="server"></asp:TextBox>
<asp:TextBox ID="NewPassword" runat="server"></asp:TextBox>
<asp:TextBox ID="ConfirmChangedPassword" runat="server"></asp:TextBox>
<br />
<br />
<br />
<asp:Button ID="btn1" runat="server" Text="hide" />
</asp:Panel>
</div>
</form>

Why ImageButton Display Text SubmitQuery Runtime

i use imagebutton in datalist and set codeexpression :Eval("PictureUrl", "ProductImages\thumb_{0}") and runtime display submitquery.
<asp:DataList ID="DataList1" runat="server" DataKeyField="pid"
DataSourceID="SqlDataSource1">
<ItemTemplate>
pname:
<asp:Label ID="pnameLabel" runat="server" Text='<%# Eval("pname") %>' />
<br />
pprice:
<asp:Label ID="ppriceLabel" runat="server" Text='<%# Eval("pprice") %>' />
<br />
publisher:
<asp:Label ID="publisherLabel" runat="server" Text='<%# Eval("publisher") %>' />
<br />
writer:
<asp:Label ID="writerLabel" runat="server" Text='<%# Eval("writer") %>' />
<br />
<asp:ImageButton ID="ImageButton7" runat="server"
ImageUrl='<%# Eval("PictureUrl", "ProductImages\thumb_{0}") %>' />
<br />
</ItemTemplate>
</asp:DataList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:dbpath %>"
SelectCommand="SELECT [pname], [pprice], [PictureUrl], [gid], [storeid], [publisher], [writer], [pid] FROM [tblproduct]">
</asp:SqlDataSource>
output one record:
pname:
<span id="ContentPlaceHolder1_DataList1_pnameLabel_0">تکنیک عکاسی</span>
<br />
pprice:
<span id="ContentPlaceHolder1_DataList1_ppriceLabel_0">125000 </span>
<br />
publisher:
<span id="ContentPlaceHolder1_DataList1_publisherLabel_0">اسرار دانش</span>
<br />
writer:
<span id="ContentPlaceHolder1_DataList1_writerLabel_0">نصرالله کسرائیان</span>
<br />
<input type="image" name="ctl00$ContentPlaceHolder1$DataList1$ctl00$ImageButton7" id="ContentPlaceHolder1_DataList1_ImageButton7_0" src="ProductImages%09humb_~/image/tecnikakasi.jpg" />
You got the correct HTML rendered
<asp:ImageButton ID="ImageButton7" runat="server"
ImageUrl='<%# Eval("PictureUrl", "ProductImages\thumb_{0}") %>' />
will produce input tag with type=image
<input type="image" name="ctl00$ContentPlaceHolder1$DataList1$ctl00$ImageButton7" id="ContentPlaceHolder1_DataList1_ImageButton7_0" src="ProductImages%09humb_~/image/tecnikakasi.jpg" />
The problem is ProductImages%09humb_~/image/tecnikakasi.jpg not exists. It may be wrong.
Check the relative path rendered.
Try
ImageUrl='<%# Eval("PictureUrl", "~/ProductImages/thumb_{0}") %>'
It is displaying "SubmitQuery" because your image is not being loaded. If your writer alternate text, then alternate text will be displayed.
You can view source of the generated html and check the path of the image and try to correct it for resolving this problem.
ImageUrl='<%# Eval("PictureUrl", "{0}") %>'

Aligning .aspx buttons

I have an update panel that contains a label, a dropDownList and two buttons:
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div id="dropDownList" style="position:relative;" runat="server">
<label>
Select New File: </label>
<div id="ddl" runat="server">
<asp:DropDownList runat="server" ID="ddlCaseFiles" DataSourceID="dsMyCaseFiles" DataTextField="Display"
DataValueField="FileID" OnPreRender="ddl_PreRender" Width="524px" OnSelectedIndexChanged="ddlCaseFiles_SelectedIndexChanged" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="ddlCaseFiles"
ToolTip="Casefile Required" InitialValue="-1" Text="*" Display="Dynamic" />
<ajaxToolkit:ListSearchExtender ID="ddlExtCaseFiles" runat="server" PromptCssClass="ListSearchExtenderPrompt"
TargetControlID="ddlCaseFiles" BehaviorID="ddlExtCaseFiles" Enabled="True" />
</div>
<br />
<asp:Button ID="btnMoveCaseFile" runat="server" Text=""
style="float:left;" onclick="btnMoveCaseFile_Click"/>
<asp:Button ID="btnCancel" runat="server" Text="Cancel"
style="float:right" onclick="btnCancel_Click"/>
<br />
</div>
<asp:Label runat="server" ID="lblStatus"></asp:Label>
</ContentTemplate>
I am trying to get my buttons to line up like this:(button at the beginning of the DropDownList and a button at the End)
I've tried float-absolute etc.
I figured it out. Seems as though you have to add in px after the number.....
<asp:Button ID="btnMoveCaseFile" runat="server" Text=""
style="position:absolute; float:left; margin-left:104px;" onclick="btnMoveCaseFile_Click"/>
<asp:Button ID="btnCancel" runat="server" Text="Cancel"
style="position:relative; float:right; margin-right:63px;"
since I had margin-right:63; instead of margin-right:63px;

ASP.NET Panel Not Ending

I have created an ASP.NET page with an AJAX Accordion control. Within on the panes are several controls, some of which I've placed inside a Panel control, for various reasons.
However, controls which are on the page AFTER the closing tag for the panel are appearing INSIDE the panel when the page is rendered. For the life me I can't figure out why, and it's driving me crazy! Even clicking on the header of the Accordion Pane after the one containing the panel doesn't cause the Pane to expand, which it did before I added the Panel, seemingly because even IT is behaving as if it's within the Panel!
Any ideas what I'm doing wrong? How can I make the page believe that the panel ends!!?
<asp:Accordion ID="accQuestionnaire" runat="server" RequireOpenedPane="false" ContentCssClass="AccordionContent" HeaderCssClass="AccordionHeader" FadeTransitions="true"
transitionduration="250" HeaderSelectedCssClass="AccordionSelected" SelectedIndex="0" SuppressHeaderPostbacks="true" >
<Panes>
<%--START OF Tristan Link Pane (0)-------------------------------------------------------------%>
<asp:AccordionPane ID="pnTristanLink" runat="server" ContentCssClass="AccordionContent" ViewStateMode="Enabled" >
<Header>
Tristan Link
</Header>
<Content>
<div class="centrebuttonsdiv" >
<asp:Button ID="btnSearchTristan" runat="server" CssClass="largebutton" Text="Search Tristan" /><br />
</div>
<asp:Panel ID="pnlTristanSearch" runat="server" CssClass="panel" >
<div class="leftdiv"> <%--Matching Tristan results--%>
<asp:FormView ID="fvTristanSearch" runat="server" CssClass="FormView" >
<ItemTemplate>
<asp:Label ID="lblTristanSearchLabel" runat="server" CssClass="fieldtitle" Text="The information from Tristan for this Case Number is:" /><br /><br />
<asp:Label ID="lblAnimalNameLabel" runat="server" CssClass="fieldtitle" Text="Horse Name: " />
<asp:Label ID="lblAnimalName" runat="server" Text='<%# Eval("PetName") & " " & Eval("ClientNameLast") %>' /><br />
<asp:Label ID="lblGenderLabel" runat="server" CssClass="fieldtitle" Text="Sex: " />
<asp:Label ID="lblGender" runat="server" Text='<%# Eval("L_GenderDesc") %>' /><br />
<asp:Label ID="lblBreedLabel" runat="server" CssClass="fieldtitle" Text="Breed: " />
<asp:Label ID="lblBreed" runat="server" Text='<%# Eval("L_BreedDesc") %>' /><br />
<asp:Label ID="lblDOBLabel" runat="server" CssClass="fieldtitle" Text="DOB: " />
<asp:Label ID="lblDOB" runat="server" Text='<%# Eval("PetDOB", "{0:d}") %>' /><br /><br />
</ItemTemplate>
</asp:FormView>
</div>
<div class="rightdiv">
<br /><br />
<asp:Label ID="lblUnmatchedAppointments" runat="server" Text="Appointments for this horse with no Colic Study details:" Visible="false" /><br />
<asp:ListBox ID="lstUnmatchedAppointments" runat="server" DataSourceID="SQLUnmatchedAppointments" DataTextField="AppointmentDate" DataTextFormatString="{0:d}" DataValueField="AppointmentID"
Visible = "False" />
</div>
<div class="cleardiv" />
</asp:Panel>
<div class="centrebuttonsdiv" >
<asp:Label ID="lblTristanSearchInstructions" runat="server" Text="Select an appointment from the list above and click 'Save Section' to continue. Otherwise, click 'Clear Retrieved Information'
to search again" Visible="false" /><br />
<asp:Button ID="btnClearTristanSearch" runat="server" Text="Clear Retrieved Information" Visible="false" CssClass="largebutton" />
<asp:Button ID="btnSaveTristanLink" runat="server" Text="Save Section" OnClientClick="disablePanes()" Visible="false" Enabled="false" CssClass="largebutton" />
</div>
</Content>
</asp:AccordionPane>
I believe that changing this line:
<div class="cleardiv" />
to this
<div class="cleardiv"></div>
will solve that rendering problem; <div> is not typically a self-closing tag.

Resources