Insert data quarterly into SQL Server table from C# - c#

I am creating a web app in C#, I have a dropdownlist like this
<asp:DropDownList ID="droptaskrpt" AutoPostBack="true" CssClass="form-control" OnTextChanged="droptaskrpt_TextChanged" runat="server">
<asp:ListItem Selected="True">Select</asp:ListItem>
<asp:ListItem>Weekly</asp:ListItem>
<asp:ListItem>Quarterly</asp:ListItem>
<asp:ListItem>Half Yearly</asp:ListItem>
<asp:ListItem>Yearly</asp:ListItem>
</asp:DropDownList>
If a user selects quarterly, the same data should be re-insert into the table with same value after a quarter.
I am not able to understand what I need to do here:
I will write the code on pageload
how can I validate the quarter?
how can I insert the same data into the table?
I need your help
<div class="panel-body" style="min-height: 500px;">
<div class="row">
<div class="col-sm-12">
<div class="row">
<div class="col-sm-6">
<div class="form-group" style="margin-top: 2px">
<asp:HiddenField ID="hfTask" runat="server" />
<asp:HiddenField ID="hfParentId" runat="server" />
<%--<asp:CheckBox ID="chkmulti" runat="server" Text="Assign to Group" AutoPostBack="true" ValidationGroup="grp" />--%>
<br />
<div runat="server" id="divuserSelect">
<asp:DropDownList ID="ddlUser" runat="server" CssClass="form-control"></asp:DropDownList>
</div>
<div runat="server" id="divmultiSelect" visible="false">
<asp:TextBox ID="txtCustomer" Text="Select Customers" runat="server" CssClass="form-control"></asp:TextBox>
<asp:Panel ID="PnlCust" runat="server" CssClass="PnlDesign">
<asp:CheckBoxList ID="cblCustomerList" runat="server">
<asp:ListItem>Customer One</asp:ListItem>
<asp:ListItem>Customer Two</asp:ListItem>
<asp:ListItem>Customer Three</asp:ListItem>
</asp:CheckBoxList>
</asp:Panel>
<asp:PopupControlExtender ID="PceSelectCustomer" runat="server" TargetControlID="txtCustomer"
PopupControlID="PnlCust" Position="Bottom">
</asp:PopupControlExtender>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
Task Title
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" ValidationGroup="OnUpdate" runat="server" Text="*" CssClass="error" ControlToValidate="txtTaskTitle"></asp:RequiredFieldValidator>
<asp:TextBox ID="txtTaskTitle" runat="server" CssClass="form-control"></asp:TextBox>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-4">
<div class="form-group" style="margin-top: 7px">
Start Date
<asp:TextBox ID="txtStartDate" runat="server" CssClass="form-control"></asp:TextBox>
<asp:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtStartDate" Format="dd MMM yyyy"></asp:CalendarExtender>
</div>
</div>
<div class="col-sm-2">
<div class="form-group">
Start Time
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ValidationGroup="OnUpdate" runat="server" Text="*" CssClass="error" ControlToValidate="txtStartTime"></asp:RequiredFieldValidator>
<asp:TextBox ID="txtStartTime" runat="server" CssClass="form-control"></asp:TextBox>
<asp:MaskedEditExtender ID="MaskedEditExtender2" runat="server" TargetControlID="txtStartTime" MaskType="Time" AcceptAMPM="true"
Mask="99:99" ErrorTooltipEnabled="true" />
<h4 style="font-size: x-small">Type A or P to switch AM/PM</h4>
</div>
</div>
<div class="col-sm-4">
<div class="form-group" style="margin-top: 7px">
End Date
<asp:TextBox ID="txtEndDate" runat="server" CssClass="form-control"></asp:TextBox>
<asp:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="txtEndDate" Format="dd MMM yyyy"></asp:CalendarExtender>
</div>
</div>
<div class="col-sm-2">
<div class="form-group">
End Time
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" ValidationGroup="OnUpdate" runat="server" Text="*" CssClass="error" ControlToValidate="txtEndTime"></asp:RequiredFieldValidator>
<asp:TextBox ID="txtEndTime" runat="server" CssClass="form-control"></asp:TextBox>
<asp:MaskedEditExtender ID="MaskedEditExtender1" runat="server" TargetControlID="txtEndTime" MaskType="Time" AcceptAMPM="true"
Mask="99:99" ErrorTooltipEnabled="true" />
<h4 style="font-size: x-small">Type A or P to switch AM/PM</h4>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
Description
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" ValidationGroup="OnUpdate" runat="server" Text="*" CssClass="error" ControlToValidate="txtDescription"></asp:RequiredFieldValidator>
<asp:TextBox ID="txtDescription" runat="server" TextMode="MultiLine" Height="100" CssClass="form-control"></asp:TextBox>
</div>
</div>
<%-- checklist for week days --%>
<div class="col-sm-6">
<h4>Task Repeat</h4>
<asp:DropDownList ID="droptaskrpt" AutoPostBack="true" CssClass="form-control" OnTextChanged="droptaskrpt_TextChanged" runat="server">
<asp:ListItem Selected="True">Select</asp:ListItem>
<asp:ListItem>Weekly</asp:ListItem>
<asp:ListItem>Quarterly</asp:ListItem>
<asp:ListItem>Half Yearly</asp:ListItem>
<asp:ListItem>Yearly</asp:ListItem>
</asp:DropDownList>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<asp:CheckBoxList ID="chkWeek" Visible="false" runat="server" CssClass="checkbox-inline">
<asp:ListItem Value="1">Monday</asp:ListItem>
<asp:ListItem Value="2">Tuesday</asp:ListItem>
<asp:ListItem Value="3">Wednesday</asp:ListItem>
</asp:CheckBoxList>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<asp:CheckBoxList ID="CheckBoxList1" Visible="false" runat="server" CssClass="checkbox-inline">
<asp:ListItem Value="4">Thursday</asp:ListItem>
<asp:ListItem Value="5">Friday</asp:ListItem>
<asp:ListItem Value="6">Saturday</asp:ListItem>
<%--<asp:ListItem Value="7">Sunday</asp:ListItem>--%>
</asp:CheckBoxList>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<br />
<div class="form-group">
<asp:FileUpload ID="fpTask" runat="server" CssClass="btn btn-block btn-warning" />
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" ValidationExpression="([a-zA-Z0-9\s_\\.$&*##()+\-:])+(.doc|.docx|.pdf|.jpg|.png|.jpeg|.xls|.xlsx|.txt|.gif)$"
ControlToValidate="fpTask" runat="server" ForeColor="Red" ErrorMessage="selected file is not valid"
Display="Dynamic" />
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
Task Priority
<asp:DropDownList runat="server" ID="ddlPriority" CssClass="form-control">
<asp:ListItem Value="Low">Low</asp:ListItem>
<asp:ListItem Value="Medium">Medium</asp:ListItem>
<asp:ListItem Value="High">High</asp:ListItem>
</asp:DropDownList>
</div>
</div>
</div>
<%--<div class="row" runat="server" id="divuser">
<div class="col-sm-6">
<div class="form-group">
User Feedback
<asp:TextBox ID="txtUserFeedBack" runat="server" class="form-control"></asp:TextBox>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<asp:CheckBox ID="chkIsUserClose" runat="server" CssClass="checkbox-inline" Text="Close By User" />
</div>
</div>
</div>--%>
<%--<div class="row" runat="server" id="divadmin">
<div class="col-sm-6">
<div class="form-group">
Admin Feedback
<asp:TextBox ID="txtAdminFeedback" runat="server" class="form-control"></asp:TextBox>
</div>
</div>
<div class="col-sm-6" style="margin-top: 17px">
<div class="form-group">
<asp:CheckBox ID="chkIsAdminClose" runat="server" CssClass="checkbox-inline" Text="Close by Admin" />
</div>
</div>
</div>--%>
<%--<div class="row" runat="server" id="divrating">
<div class="col-sm-6">
<div class="form-group">
Rating
<asp:TextBox ID="txtRating" runat="server" CssClass="form-control"></asp:TextBox>
</div>
</div>
</div>--%>
</div>
</div>
<div class="row">
<div class="col-sm-3">
<%--<asp:ImageButton ID="btnRefresh" runat="server" ImageUrl="~/Content/Images/refresh.png" />--%>
</div>
<div class="col-sm-3">
<asp:Button ID="btnUpdate" runat="server" CssClass="btn btn-primary btn-lg" Text="Update" ValidationGroup="OnUpdate" OnClick="btnUpdate_Click" />
</div>
</div>
<div>
<asp:GridView CssClass="Grid" ID="dgvTask" runat="server" AutoGenerateColumns="false" AllowPaging="true" PageSize="10" OnPageIndexChanging="dgvTask_PageIndexChanging" OnRowDeleting="dgvTask_RowDeleting">
<Columns>
<asp:TemplateField Visible="false">
<ItemTemplate>
<asp:Label runat="server" ID="lblTaskId" Text='<%# Eval("TaskAutoId") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Sr.No">
<ItemTemplate>
<asp:Label runat="server" ID="lblSrNo" Text='<%# Eval("SrNo") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="5%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Task">
<ItemTemplate>
<asp:Label runat="server" ID="lblTask" Text='<%# Eval("TaskName")+": "+Eval("TaskDescription") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="50%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Assign To">
<ItemTemplate>
<asp:Label runat="server" ID="lblAssignTo" Text='<%# Eval("AssignTo") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="10%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Start Date">
<ItemTemplate>
<asp:Label runat="server" ID="lblTaskAssignDate" Text='<%# Eval("AssignDate") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="10%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="End Date">
<ItemTemplate>
<asp:Label runat="server" ID="lblTaskEndDate" Text='<%# Eval("EndDate") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="10%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Action">
<ItemTemplate>
<asp:LinkButton ID="lnkDelete" runat="server" CommandName="Delete" Text="Delete" CssClass="action" />
</ItemTemplate>
<ItemStyle Width="10%" />
</asp:TemplateField>
</Columns>
<PagerStyle CssClass="paging" />
</asp:GridView>
</div>
<br />
</div>
all the required html objects

Related

Identifying the selected row count in a Telerik RadGrid

I am using Telerik's RadGrid control in a form, along with a FormView. When I select a row in the RadGrid, the details of the selected row display in the FormView control. There's also a button on the page that, when clicked, changes the mode of the FormView to "Insert", but only if a row in the RadGrid is selected. Otherwise a label should appear. Unfortunately, I can't get the count of selected items in the RadGrid to ever count more than 0. This means that I always see the label text when I click the button, even if a row is selected in the RadGrid.
Here's the RadGrid markup:
<telerik:RadGrid ID="rgInsps" runat="server" DataSourceID="sdsRgInsps" AutoGenerateColumns="False" AllowPaging="True" AllowSorting="True" AllowFilteringByColumn="True" ShowGroupPanel="True" Skin="Default" OnSelectedIndexChanged="rgInsps_SelectedIndexChanged" OnPreRender="rgInsps_PreRender" OnItemCommand="rgInsps_ItemCommand">
<ClientSettings AllowDragToGroup="True" AllowColumnsReorder="True" ReorderColumnsOnClient="True"></ClientSettings>
<MasterTableView DataKeyNames="inspDetIdPk" DataSourceID="sdsRgInsps">
<Columns>
<telerik:GridButtonColumn ButtonType="LinkButton" CommandName="Select" Text="Select"></telerik:GridButtonColumn>
<telerik:GridBoundColumn DataField="inspDetIdPk" ReadOnly="True" HeaderText="inspDetIdPk" SortExpression="inspDetIdPk" UniqueName="inspDetIdPk" DataType="System.Int32" FilterControlAltText="Filter inspDetIdPk column"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="assntIdFk" HeaderText="assntIdFk" SortExpression="assntIdFk" UniqueName="assntIdFk" DataType="System.Int32" FilterControlAltText="Filter assntIdFk column" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Font-Bold="false" ItemStyle-HorizontalAlign="Center"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="inspDt" HeaderText="Inspection Date" DataFormatString="{0:MM/dd/yyyy}" SortExpression="inspDt" UniqueName="inspDt" DataType="System.DateTime" FilterControlAltText="Filter inspDt column" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Font-Bold="false" ItemStyle-HorizontalAlign="Center"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="inspContDt" HeaderText="Contact Date" DataFormatString="{0:MM/dd/yyyy}" SortExpression="inspContDt" UniqueName="inspContDt" DataType="System.DateTime" FilterControlAltText="Filter inspContDt column" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Font-Bold="false" ItemStyle-HorizontalAlign="Center"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="contType" HeaderText="Contact Type" SortExpression="contType" UniqueName="contType" FilterControlAltText="Filter contType column" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Font-Bold="false" ItemStyle-HorizontalAlign="Center"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="inspContFN" HeaderText="First Name" SortExpression="inspContFN" UniqueName="inspContFN" FilterControlAltText="Filter inspContFN column" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Font-Bold="false" ItemStyle-HorizontalAlign="Center"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="inspContLN" HeaderText="Last Name" SortExpression="inspContLN" UniqueName="inspContLN" FilterControlAltText="Filter inspContLN column" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Font-Bold="false" ItemStyle-HorizontalAlign="Center"></telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
Here's the FormView markup:
<asp:FormView ID="fvInspsDets"
runat="server"
DataKeyNames="inspDetIdPk"
DataSourceID="sdsFvInspDets"
OnItemCommand="fvInspsDets_ItemCommand"
OnItemUpdated="fvInspsDets_ItemUpdated"
OnItemInserted="fvInspsDets_ItemInserted"
OnItemDeleted="fvInspsDets_ItemDeleted">
<EditItemTemplate>
<asp:Label Text='<%# Eval("inspDetIdPk") %>' runat="server" ID="inspDetIdPkLabel1" Visible="false" />
<asp:TextBox Text='<%# Bind("assntIdFk") %>' runat="server" ID="assntIdFkTextBox" Visible="false" />
<asp:TextBox Text='<%# Bind("inspDetUpldBy") %>' runat="server" ID="inspDetUpldByTextBox" Visible="false" />
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-3 col-lg-3 form-group">
<strong>Contact Date & Time</strong><br />
<asp:TextBox ID="inspContDtTextBox" runat="server" Text='<%# Bind("inspContDt", "{0:MM/dd/yyyy}") %>' CssClass="form-control"></asp:TextBox>
<ajaxToolkit:CalendarExtender ID="cdInspContDtTextBox" runat="server" TargetControlID="inspContDtTextBox" Format="MM/dd/yyyy" />
</div>
<div class="col-xs-12 col-sm-6 col-md-3 col-lg-3 form-group">
<strong>Contact Type</strong><br />
<asp:DropDownList SelectedValue='<%# Bind("inspContType") %>' runat="server" ID="inspContTypeDdl" CssClass="form-control" AppendDataBoundItems="true" DataSourceID="sdsContTypes" DataTextField="contType" DataValueField="contTypeIdPk"><asp:ListItem Value="">--Please Select--</asp:ListItem></asp:DropDownList>
</div>
<div class="col-xs-12 col-sm-6 col-md-3 col-lg-3 form-group">
<strong>Contact's First Name</strong><br />
<asp:TextBox Text='<%# Bind("inspContFN") %>' runat="server" ID="inspContFNTextBox" CssClass="form-control" />
</div>
<div class="col-xs-12 col-sm-6 col-md-3 col-lg-3 form-group">
<strong>Contact's Last Name</strong><br />
<asp:TextBox Text='<%# Bind("inspContLN") %>' runat="server" ID="inspContLNTextBox" CssClass="form-control" />
</div>
<div class="col-xs-12 col-sm-6 col-md-3 col-lg-3 form-group">
<strong>Inspection Date & Time</strong><br />
<asp:TextBox ID="inspDtTextBox" runat="server" Text='<%# Bind("inspDt", "{0:MM/dd/yyyy}") %>' CssClass="form-control"></asp:TextBox>
<ajaxToolkit:CalendarExtender ID="ceInspDtTextBox" runat="server" TargetControlID="inspDtTextBox" Format="MM/dd/yyyy" />
</div>
<div class="col-xs-12 col-sm-6 col-md-3 col-lg-3 form-group">
<strong>Inspection Rescheduled</strong><br />
<asp:CheckBox Checked='<%# Bind("inspResched") %>' runat="server" ID="inspReschedCheckBox" />
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 form-group">
<strong>Note(s)</strong><br />
<asp:TextBox Text='<%# Bind("inspNote") %>' runat="server" ID="inspNoteTextBox" CssClass="form-control" Rows="3" TextMode="MultiLine" />
</div>
</div>
<asp:LinkButton runat="server" Text="Update" CommandName="Update" ID="UpdateButton" CausesValidation="True" CssClass="btn btn-success btn-sm" />
<asp:LinkButton runat="server" Text="Cancel" CommandName="Cancel" ID="UpdateCancelButton" CausesValidation="False" CssClass="btn btn-danger btn-sm" />
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox Text='<%# Bind("assntIdFk") %>' runat="server" ID="assntIdFkTextBox" Visible="false" />
<asp:TextBox Text='<%# Bind("inspDetUpldBy") %>' runat="server" ID="inspDetUpldByTextBox" Visible="false" />
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-3 col-lg-3 form-group">
<strong>Contact Date & Time</strong><br />
<telerik:RadDateTimePicker ID="rdtpInspContDt" runat="server" DbSelectedDate='<%# Bind("inspContDt") %>' Skin="Default" CssClass="form-control" ></telerik:RadDateTimePicker>
</div>
<div class="col-xs-12 col-sm-6 col-md-3 col-lg-3 form-group">
<strong>Contact Type</strong><br />
<asp:DropDownList SelectedValue='<%# Bind("inspContType") %>' runat="server" ID="inspContTypeDdl" CssClass="form-control" AppendDataBoundItems="true" DataSourceID="sdsContTypes" DataTextField="contType" DataValueField="contTypeIdPk"><asp:ListItem Value="">--Please Select--</asp:ListItem></asp:DropDownList>
</div>
<div class="col-xs-12 col-sm-6 col-md-3 col-lg-3 form-group">
<strong>Contact's First Name</strong><br />
<asp:TextBox Text='<%# Bind("inspContFN") %>' runat="server" ID="inspContFNTextBox" CssClass="form-control" />
</div>
<div class="col-xs-12 col-sm-6 col-md-3 col-lg-3 form-group">
<strong>Contact's Last Name</strong><br />
<asp:TextBox Text='<%# Bind("inspContLN") %>' runat="server" ID="inspContLNTextBox" CssClass="form-control" />
</div>
<div class="col-xs-12 col-sm-6 col-md-3 col-lg-3 form-group">
<strong>Inspection Date & Time</strong><br />
<telerik:RadDateTimePicker ID="rdtpInspDt" runat="server" DbSelectedDate='<%# Bind("inspDt") %>' CssClass="form-control"></telerik:RadDateTimePicker>
</div>
<div class="col-xs-12 col-sm-6 col-md-3 col-lg-3 form-group">
<strong>Inspection Rescheduled</strong><br />
<asp:CheckBox Checked='<%# Bind("inspResched") %>' runat="server" ID="inspReschedCheckBox" />
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 form-group">
<strong>Note(s)</strong><br />
<asp:TextBox Text='<%# Bind("inspNote") %>' runat="server" ID="inspNoteTextBox" CssClass="form-control" Rows="3" TextMode="MultiLine" />
</div>
</div>
<asp:LinkButton runat="server" Text="Insert" CommandName="Insert" ID="InsertButton" CausesValidation="True" CssClass="btn btn-success btn-sm" />
<asp:LinkButton runat="server" Text="Cancel" CommandName="Cancel" ID="InsertCancelButton" CausesValidation="False" CssClass="btn btn-danger btn-sm" />
</InsertItemTemplate>
<ItemTemplate>
<asp:Label Text='<%# Eval("inspDetIdPk") %>' runat="server" ID="inspDetIdPkLabel" Visible="false" />
<asp:Label Text='<%# Bind("assntIdFk") %>' runat="server" ID="assntIdFkLabel" Visible="false" />
<asp:Label Text='<%# Bind("inspDetUpldBy") %>' runat="server" ID="inspDetUpldByLabel" Visible="false" />
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-3 col-lg-3 form-group">
<strong>Contact Date & Time</strong><br />
<asp:Label Text='<%# Bind("inspContDt") %>' runat="server" ID="inspContDtLabel" CssClass="form-control" />
</div>
<div class="col-xs-12 col-sm-6 col-md-3 col-lg-3 form-group">
<strong>Contact Type</strong><br />
<asp:Label Text='<%# Bind("contType") %>' runat="server" ID="inspContTypeLabel" CssClass="form-control" />
</div>
<div class="col-xs-12 col-sm-6 col-md-3 col-lg-3 form-group">
<strong>Contact's First Name</strong><br />
<asp:Label Text='<%# Bind("inspContFN") %>' runat="server" ID="inspContFNLabel" CssClass="form-control" />
</div>
<div class="col-xs-12 col-sm-6 col-md-3 col-lg-3 form-group">
<strong>Contact's Last Name</strong><br />
<asp:Label Text='<%# Bind("inspContLN") %>' runat="server" ID="inspContLNLabel" CssClass="form-control" />
</div>
<div class="col-xs-12 col-sm-6 col-md-3 col-lg-3 form-group">
<strong>Inspection Date & Time</strong><br />
<asp:Label Text='<%# Bind("inspDt") %>' runat="server" ID="inspDtLabel" CssClass="form-control" />
</div>
<div class="col-xs-12 col-sm-6 col-md-3 col-lg-3 form-group">
<strong>Rescheduled</strong><br />
<asp:CheckBox Checked='<%# Bind("inspResched") %>' runat="server" ID="inspReschedCheckBox" Enabled="false" />
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 form-group">
<strong>Note(s)</strong><br />
<asp:Label Text='<%# Bind("inspNote") %>' runat="server" ID="inspNoteLabel" />
</div>
</div>
<asp:LinkButton runat="server" Text="Edit" CommandName="Edit" ID="EditButton" CausesValidation="False" CssClass="btn btn-primary btn-sm" />
<asp:LinkButton runat="server" Text="Delete" CommandName="Delete" ID="DeleteButton" CausesValidation="False" CssClass="btn btn-danger btn-sm" />
<asp:LinkButton runat="server" Text="New" CommandName="New" ID="NewButton" CausesValidation="False" CssClass="btn btn-success btn-sm" />
</ItemTemplate>
</asp:FormView>
Here's the label:
<asp:Label ID="fvInspsDetsLbl" runat="server"></asp:Label>
Here's the button:
<asp:Button ID="btnRvInspsDetsInsert"
runat="server"
Text="ADD A NEW INSPECTION"
CssClass="btn btn-default btn-sm pull-right"
OnClick="btnRvInspsDetsInsert_Click"
CausesValidation="false" />
Here's the click event code for the button:
if (rgAssnmtList.SelectedItems.Count > 0)
{
fvInspsDets.ChangeMode(FormViewMode.Insert);
}
else
{
fvInspsDetsLbl.Text = "Please select an assignment from the table at the top of the screen.";
fvInspsDetsLbl.ForeColor = System.Drawing.ColorTranslator.FromHtml("#CA2823");
}
Any help on identifying the selected item count of the RadGrid is greatly appreciated.
I am using VS2017, Asp.NET WebForms C# along with Telerik products (thus the RadGrid).
Use radGridView1.SelectedCells.Count to get selected cells, or radGridView1.SelectedRows.Count
Also use RowInfo and ColumnInfo to access the selected row and column.
Check this sample code:
this.radGridView1.MasterTemplate.BeginUpdate();
int count = this.radGridView1.SelectedCells.Count;
for (int i = 0; i < count; i++)
{
GridViewRowInfo row = this.radGridView1.SelectedCells[i].RowInfo;
GridViewColumn column = this.radGridView1.SelectedCells[i].ColumnInfo;
string text = Convert.ToString(this.radGridView1.SelectedCells[i].ColumnInfo.HeaderText);
GridViewCellInfo cell = this.radGridView1.SelectedCells[i];
double val = Convert.ToDouble(cell.Value);
}
this.radGridView1.MasterTemplate.EndUpdate();

Filtering Gridview

when I filter the Gridview I lose the Footable function.
Strange behavior, if I click on the filter button, filter by brand and select the Pireli option, then click the update button.
I lose the Footable function, but if I then click the Update button again leaving the filter as Pireli the Footable function returns!!!!!
Seeing is believing if you navigate to the following url www.tyrescanner.net
Enter registration WR08SZE
Enter postcode KA227PR
Sorry for the jumping around here.
If you click on the filer Brand option and select Pireli, the Gridview will lose the Footable function, but if you click again on the Update button the Footable function returns!!!!!!!!
<asp:Content ID="Content1" ContentPlaceHolderID="Header" runat="server">
<link href="https://cdnjs.cloudflare.com/ajax/libs/jquery-footable/0.1.0/css/footable.min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-footable/0.1.0/js/footable.min.js"></script>
<%--Resizing Gridview--%>
<script>
$(function () {
AttachjQueryFootableToTable();
});
function AttachjQueryFootableToTable() {
$('[id*=GridView1]').footable();
}
</script>
<script>
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(function () {
AttachjQueryFootableToTable();
});
</script>
<div class="row">
<div class="col-md-8 col-md-pull-0 ">
<asp:Label ID="lblRegText" runat="server" Text="Tyre Size: " Style="font-weight: 700; font-size: x-large" Visible="True"></asp:Label>
<asp:Label ID="lbltyresize" runat="server" Style="font-weight: 700; font-size: x-large" Visible="True"></asp:Label>
<a href="http://tyrescanner.net/pages/edit-tyre-size.aspx">
<asp:Label ID="lblEdit" runat="server" Text=" Edit" Style="font-size: large" Visible="True"></asp:Label>
</a>
</div>
</div>
<br />
<div class="row">
<div class="col-sm-4 col-md-4">
<div class="container">
<button type="button" class="btn btn-info" data-toggle="collapse" data-target="#demo"><span class="glyphicon glyphicon-filter">Filter</span></button>
<div id="demo" class="collapse">
<div class="row">
<div class="col-md-2 col-sm-2" style="width: 130px">
<h5><strong>Brand</strong></h5>
<asp:DropDownList ID="SRDDLBrand" runat="server" DataSourceID="SqlDataSourceBrand" DataTextField="TyreBrands" DataValueField="TyreBrands" Height="35px" Width="105px" AppendDataBoundItems="True">
<asp:ListItem Text="Select All" Value=" " />
</asp:DropDownList>
</div>
<div class="col-md-2 col-sm-2" style="width: 130px">
<h5><strong>Season</strong></h5>
<asp:DropDownList ID="SRDDLTyreType" runat="server" DataSourceID="SqlDataSourceTyreType" DataTextField="TyreType" DataValueField="TyreType" Height="35px" Width="105px" AppendDataBoundItems="True">
<asp:ListItem Text="Select All" Value=" " />
</asp:DropDownList>
</div>
<div class="col-md-2 col-sm-2" style="width: 130px">
<h5><strong>Fuel Efficiency</strong></h5>
<asp:DropDownList ID="SRDDLFuelCat" runat="server" DataSourceID="SqlDataSourceFuelCategory" DataTextField="TyreCategory" DataValueField="TyreCategory" Height="35px" Width="105px" AppendDataBoundItems="True">
<asp:ListItem Text="Select All" Value=" " />
</asp:DropDownList>
</div>
<div class="col-md-2 col-sm-2" style="width: 130px">
<h5><strong>Wet Grip</strong></h5>
<asp:DropDownList ID="SRDDLWetGrip" runat="server" DataSourceID="SqlDataSourceWetGrip" DataTextField="TyreCategory" DataValueField="TyreCategory" Height="35px" Width="105px" AppendDataBoundItems="True">
<asp:ListItem Text="Select All" Value=" " />
</asp:DropDownList>
</div>
<br />
<p></p>
<div class="col-md-2 col-sm-2">
<asp:Button ID="bntFilter" runat="server" OnClick="bntFIlter_Click" Text="Update Results" CssClass="btn Jumbt btn-custom" Style="color: white" role="button" Height="44px" />
</div>
</div>
</div>
</div>
</div>
</div>
<br />
<asp:UpdatePanel UpdateMode="Conditional" ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true">
<ContentTemplate>
<asp:GridView ID="GridView1" CssClass="footable" runat="server" AutoGenerateColumns="False" Style="max-width: 130%" AutoPostback="Flash" DataKeyNames="ProductID,GarageID" DataSourceID="SqlDataSourceGridViewSearchResults"
EmptyDataText="Sorry we don’t have that tyre, please email us your requirements and we will add it to our Search engine – service#tyrescanner.net"
OnSelectedIndexChanging="GridView1_SelectedIndexChanging" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" OnRowCommand="GridView1_RowCommand" OnRowDataBound="GridView1_RowDataBound" OnRowCreated="GridView1_RowCreated">
<Columns>
<%-- 0--%>
<asp:BoundField DataField="ProductID" HeaderText="ProductID" Visible="false" />
<%--1--%>
<asp:BoundField DataField="GarageID" HeaderText="GarageID" Visible="false" />
<%-- 2--%>
<asp:BoundField DataField="GarageTown" HeaderText="Garage Location"></asp:BoundField>
<%-- 3--%>
<asp:TemplateField HeaderText="Tyre Model">
<ItemTemplate>
<asp:Label ID="lblBrand" runat="server" Text='<%#Eval("Brand")+ " " + Eval("TyreModel")%>'></asp:Label>
<br />
<asp:Label ID="Label1" runat="server" Text="£" Height="16px" Width="4px" Font-Bold="True"></asp:Label>
<asp:Label ID="lblCurrency" runat="server" Font-Bold="True" Text='<%#Eval("ProductUnitSalePrice")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<%-- 4--%>
<asp:BoundField DataField="TyreType" HeaderText="Tyre Type" />
<%-- 5 --%>
<asp:TemplateField HeaderText="Noise Level">
<ItemTemplate>
<asp:Label ID="lblNoiseEmission" runat="server" Text='<%#Eval("NoiseEmission")+ "dB"%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="FuelEfficiencyCategory" HeaderText="Fuel Efficiency" />
<%-- 6 --%>
<asp:BoundField DataField="WetGrip" HeaderText="Wet Grip" />
<%-- 7 --%>
<asp:TemplateField HeaderText="Select Quantity">
<ItemTemplate>
<asp:DropDownList ID="txtQuantity" runat="server" OnSelectedIndexChanged="txtQuantity_SelectedIndexChanged"
AutoPostBack="true" Width="55px" Height="32px" DataFormatString="{0:£ 0.0}" ForeColor="Black">
<asp:ListItem Text="0" Value=" " />
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="Errorlabel" runat="server" Text=""></asp:Label><p></p>
<asp:Label ID="LabelTotalPoundSign" runat="server" Font-Bold="true" Text="Total £" Height="16px" Width="4px"></asp:Label>
<asp:Label ID="lblTotal" runat="server" Font-Bold="true" Text="0.00" Width="30px"></asp:Label>
<asp:LinkButton runat="server" OnClick="btnOrder_Click" CommandName="Select" class="btn btn-custom btn-sm" Style="color: white">Order »</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>

Button not working when I use update panel

I have 3 bootstrap tabs in a page. In the first and third tab buttons they are not working but a button in the second tab works fine. In the second tab I have an update panel to post back a dropdown because I want to show like bootstrap modal script and a button at second tab is working fine. Can you tell me why it's happening and how can I do this?
My question is very confusing to explain. I want to use about why a button in tab is not working but in the second tab is working fine. And when I do function in second tab finish a button in first tab is working. Why is happening? I am very confused. Thank you very much.
this is code in .aspx with function modal:
<div class="tab-pane fade" id="profile">
<%--modal --%>
<button type="button" id="aaa" data-toggle="modal" data-target="#download" class="btn btn-primary btn-lg">เพิ่มรายการใหม่</button>
<div class="modal fade" id="download" tabindex="-1" role="dialog" aria-labelledby="downloadlabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="downloadlabel">
<asp:Label ID="usrl" runat="server"></asp:Label>
<br />
<asp:Label ID="detail" runat="server"></asp:Label></h4>
</div>
<div class="modal-body">
<p>
<strong>Request Section</strong><br /><br />
</p>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:Panel ID="Panel1" runat ="server">
<asp:UpdatePanel ID="update" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<div class="formItem">
<div class="form-group">
<asp:Label ID="Label6" runat="server"><b>Item Code: </b></asp:Label>
<asp:TextBox ID="itm_code" CssClass="form-control" runat="server" required="required"></asp:TextBox>
</div>
</div>
<div class="formItem">
<div class="form-group">
<asp:Label ID="Label7" runat="server"><b>Item Description: </b></asp:Label>
<asp:TextBox ID="itm_desc" CssClass="form-control" runat="server" required="required"></asp:TextBox>
</div>
</div>
<div class="formItem">
<div class="form-group">
<asp:Label runat="server"><b>Order Category: </b></asp:Label>
<asp:DropDownList ID="ord_cat" CssClass="form-control" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ord_cat_SelectedIndexChanged">
<asp:ListItem Value="0" Text="Chosse Order Category"></asp:ListItem>
</asp:DropDownList>
</div>
</div>
<div class="formItem">
<div class="form-group">
<asp:Label runat="server"><b>Order Subcategory / Department in Lab: </b></asp:Label>
<asp:DropDownList ID="ord_subCat" CssClass="form-control" runat="server">
<asp:ListItem Value="0" Text="Chosse Order Subcategory"></asp:ListItem>
</asp:DropDownList>
</div>
</div>
<div class="formItem">
<div class="form-group">
<asp:Label ID="Label11" runat="server"><b>Billing Group: </b></asp:Label>
<asp:DropDownList ID="ord_bg" CssClass="form-control" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ord_bg_SelectedIndexChanged">
<asp:ListItem Value="0" Text="Chosse Billing Group"></asp:ListItem>
</asp:DropDownList>
</div>
</div>
<div class="formItem">
<div class="form-group">
<asp:Label ID="Label14" runat="server"><b>Billing SubGroup: </b></asp:Label>
<asp:DropDownList ID="ord_bsg" CssClass="form-control" runat="server">
<asp:ListItem Value="0" Text="Chosse Billing Sub Group"></asp:ListItem>
</asp:DropDownList>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
<div class="formItem">
<div class="form-group">
<asp:Label runat="server"><b>Service Cat: </b></asp:Label>
<asp:TextBox ID="ord_svc" CssClass="form-control" runat="server"></asp:TextBox>
</div>
</div>
<div class="formItem">
<div class="form-group">
<asp:Label runat="server"><b>Alias Name / Synonym in Lab: </b></asp:Label>
<asp:TextBox ID="ord_asn" CssClass="form-control" runat="server" required="required"></asp:TextBox>
</div>
</div>
<div class="formItem">
<div class="form-group">
<asp:Label runat="server"><b>Cost Price: </b></asp:Label>
<asp:TextBox ID="ord_cp" CssClass="form-control" runat="server" required="required"></asp:TextBox>
</div>
</div>
<div class="formItem">
<div class="form-group">
<div class="form-inline">
<asp:Label runat="server"><b>OPD Price: </b></asp:Label>
<asp:TextBox ID="OPD_price" size="7" CssClass="form-control" runat="server" required="required"></asp:TextBox>
<asp:Label runat="server"><b>IPD Price: </b></asp:Label>
<asp:TextBox ID="IPD_price" size="7" CssClass="form-control" runat="server" required="required"></asp:TextBox>
<asp:Label runat="server"><b>Tourist Price: </b></asp:Label>
<asp:TextBox ID="TOU_price" size="7" CssClass="form-control" runat="server" required="required"></asp:TextBox>
</div>
</div>
</div>
<div class="formItem">
<div class="form-group">
<asp:Label runat="server"><b>File upload</b></asp:Label>
<asp:FileUpload ID="fileupload" runat="server" />
<p class="help-block" style="color: #FF852C">โปรดระบุ เอกสารแนบท้ายเพิ่มเติมกรณี (ถ้ามี)</p>
</div>
</div>
<div class="formItem">
<div class="form-group">
<asp:Label runat="server"><b>Send to DF: </b></asp:Label>
<asp:RadioButtonList ID="ord_sdf" runat="server" CssClass="required">
<asp:ListItem Value="Yes" Text="Yes"></asp:ListItem>
<asp:ListItem Value="No" Text="No"></asp:ListItem>
</asp:RadioButtonList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator" runat="server" ControlToValidate="ord_sdf" ErrorMessage="Please select some other choice.">
</asp:RequiredFieldValidator>
</div>
</div>
<div class="formItem">
<div class="form-group">
<asp:Label runat="server"><b>Remark: </b></asp:Label>
<asp:TextBox ID="ord_rmk" TextMode="MultiLine" CssClass="form-control" runat="server"></asp:TextBox>
</div>
</div>
</div>
<div class="modal-footer">
<asp:Button ID="btn_insert" CssClass="btn btn-danger" Text="INSERT ITEM" runat="server" OnClick="btn_insert_Click" />
<button type="button" class="btn btn-info" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
code in tab 1
<div class="tab-content">
<div class="tab-pane fade in active" id="home">
<div class="search">
<div class="form-inline">
<div class="group-search">
<asp:Label ID="Label12" Text="Item Code : " runat="server" CssClass="control-label" Font-Bold ="true"></asp:Label>
<asp:TextBox ID="search_ic" runat="server" CssClass="form-control"></asp:TextBox>
<asp:Label ID="Label13" Text="Item Description : " runat="server" CssClass="control-label" Font-Bold ="true"></asp:Label>
<asp:TextBox ID="search_id" runat="server" CssClass="form-control"></asp:TextBox>
<asp:Button ID="btn_search" Text="Search" runat="server" CssClass="btn btn-default" OnClick="btn_search_Click" />
<asp:Label ID="txt_alert" Text="กรุณากรอก Item Code หรือ Item Description" runat="server" CssClass="form-control" Visible="false"></asp:Label>
</div>
</div>
</div>
<%--gridview for update--%>
<div class="meddle2">
<asp:GridView ID="gridview" runat="server" AutoGenerateColumns="False"
OnDataBound="gridview_DataBound"
OnRowCancelingEdit="gridview_RowCancelingEdit"
OnRowEditing="gridview_RowEditing" OnRowUpdated="gridview_RowUpdated"
CssClass="table table-hover table-striped">
<Columns>
<asp:CommandField ShowEditButton="True" HeaderStyle-BackColor="#D4E6ED" ControlStyle-CssClass="btn btn-primary" ButtonType="Button" HeaderStyle-Width="80">
<ControlStyle CssClass="btn btn-primary"></ControlStyle>
<HeaderStyle Width="80px"></HeaderStyle>
</asp:CommandField>
<asp:TemplateField HeaderText="No." HeaderStyle-BackColor="#D4E6ED">
<ItemTemplate>
<asp:Label ID="lblnum" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.num") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Item Code" HeaderStyle-BackColor="#D4E6ED">
<ItemTemplate>
<asp:Label ID="lblIC" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.item_code") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txt_ic" runat="server" size="6" CssClass="form-control" Text='<%# DataBinder.Eval(Container, "DataItem.item_code") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Item Description" HeaderStyle-BackColor="#D4E6ED">
<ItemTemplate>
<asp:Label ID="lblID" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.item_des") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txt_id" runat="server" size="10" CssClass="form-control" Text='<%# DataBinder.Eval(Container, "DataItem.item_des") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Existing OPD Price" HeaderStyle-BackColor="#D4E6ED">
<ItemTemplate>
<asp:Label ID="lblEOP" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.eop") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txt_eop" runat="server" size="10" CssClass="form-control" Text='<%# DataBinder.Eval(Container, "DataItem.eop") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Existing IPD Price" HeaderStyle-BackColor="#D4E6ED">
<ItemTemplate>
<asp:Label ID="lblEIP" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.eip") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txt_eip" runat="server" size="10" CssClass="form-control" Text='<%# DataBinder.Eval(Container, "DataItem.eip") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Existing Tourist Price" HeaderStyle-BackColor="#D4E6ED">
<ItemTemplate>
<asp:Label ID="lblETP" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.etp") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txt_etp" runat="server" size="10" CssClass="form-control" Text='<%# DataBinder.Eval(Container, "DataItem.etp") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="New OPD Price" HeaderStyle-BackColor="#D4E6ED">
<ItemTemplate>
<asp:Label ID="lblNOP" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.nop") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txt_nop" runat="server" size="10" CssClass="form-control" Text='<%# DataBinder.Eval(Container, "DataItem.nop") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="New IPD Price" HeaderStyle-BackColor="#D4E6ED">
<ItemTemplate>
<asp:Label ID="lblNIP" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.nip") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txt_nip" runat="server" size="10" CssClass="form-control" Text='<%# DataBinder.Eval(Container, "DataItem.nip") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="New Tourist Price" HeaderStyle-BackColor="#D4E6ED">
<ItemTemplate>
<asp:Label ID="lblNTP" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.ntp") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txt_ntp" runat="server" size="10" CssClass="form-control" Text='<%# DataBinder.Eval(Container, "DataItem.ntp") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Margin OPD Price" HeaderStyle-BackColor="#D4E6ED">
<ItemTemplate>
<asp:Label ID="lblmop" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.mop") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txt_mop" runat="server" size="10" CssClass="form-control" Text='<%# DataBinder.Eval(Container, "DataItem.mop") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Margin IPD Price" HeaderStyle-BackColor="#D4E6ED">
<ItemTemplate>
<asp:Label ID="lblmip" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.mip") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txt_mip" runat="server" size="10" CssClass="form-control" Text='<%# DataBinder.Eval(Container, "DataItem.mip") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Margin Tourist Price" HeaderStyle-BackColor="#D4E6ED">
<ItemTemplate>
<asp:Label ID="lblmtp" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.mtp") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txt_mtp" runat="server" size="10" CssClass="form-control" Text='<%# DataBinder.Eval(Container, "DataItem.mtp") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:HiddenField ID="hdf" runat="server" />
</div>
</div>

Random sequence of html div tags position

There is four Div tags in this GridView with ID="NUMBER1" ID="NUMBER2" ID="NUMBER3" ID="NUMBER4" values and i want to change the sequence of their position in page randomly in every row of the gridview.
what is the best and most simple SERVER SIDE method to do this.
I'm new to asp.net using C# language.
<body>
<asp:GridView OnRowCommand="SelectedPollGridView_RowCommand" ID="SelectedPollGridView" runat="server" AutoGenerateColumns="False" DataKeyNames="QuesID" DataSourceID="SelectedPollSqlDataSource">
<Columns>
<asp:TemplateField HeaderText="Questions">
<ItemTemplate>
<div runat="server" id="MainDiv" class="text-right col-md-12">
<div class="row ">
<div dir="rtl" class="col-md-12 text-right">
<p runat="server" id="BodyPTag"><%#Eval("Body") %></p>
<asp:Label Visible="false" ID="QuesIDLabel" runat="server" Text='<%#Eval("QuesID") %>'></asp:Label>
</div>
</div>
<div id="NUMBER1" runat="server" class="row ">
<div class="col-md-12">
<div dir="rtl" runat="server" id="Div2" class="text-right col-md-11">
<asp:Label ID="Label1" runat="server" Text='<%#Eval("O1") %>'></asp:Label>
</div>
<div runat="server" id="Div3" class="text-right col-md-1">
<asp:Button CommandArgument='<%# ((GridViewRow) Container).RowIndex %>' CommandName="O1" CssClass='<%#Eval("O1Css") %>' ID="O1Button" runat="server" Text="Option 1" />
</div>
</div>
</div>
<div id="NUMBER2" runat="server" class="row ">
<div class="col-md-12">
<div dir="rtl" runat="server" id="Div4" class="text-right col-md-11">
<asp:Label ID="Label2" runat="server" Text='<%#Eval("O2") %>'></asp:Label>
</div>
<div runat="server" id="Div5" class="text-right col-md-1">
<asp:Button CommandArgument='<%# ((GridViewRow) Container).RowIndex %>' CommandName="O2" CssClass='<%#Eval("O2Css") %>' ID="O2Button" runat="server" Text="Option 2" />
</div>
</div>
</div>
<div id="NUMBER3" runat="server" class="row ">
<div class="col-md-12">
<div dir="rtl" runat="server" id="Div6" class="text-right col-md-11">
<asp:Label ID="Label3" runat="server" Text='<%#Eval("O3") %>'></asp:Label>
</div>
<div runat="server" id="Div7" class="text-right col-md-1">
<asp:Button CommandArgument='<%# ((GridViewRow) Container).RowIndex %>' CommandName="O3" CssClass='<%#Eval("O3Css") %>' ID="O3Button" runat="server" Text="Option 3" />
</div>
</div>
</div>
<div id="NUMBER4" runat="server" class="row ">
<div class="col-md-12">
<div dir="rtl" runat="server" id="Div8" class="text-right col-md-11">
<asp:Label ID="Label4" runat="server" Text='<%#Eval("O4") %>'></asp:Label>
</div>
<div runat="server" id="Div9" class="text-right col-md-1">
<asp:Button CommandArgument='<%# ((GridViewRow) Container).RowIndex %>' CommandName="O4" CssClass='<%#Eval("O4Css") %>' ID="O4Button" runat="server" Text="Option 4" />
</div>
</div>
</div>
</div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SelectedPollSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:GUOTSConnectionString %>" SelectCommand="SELECT DISTINCT QuesID, Body, O1, O2, O4, O3, O1Css, O2Css, O4Css, O3Css, Time, BookRange, UserID, CourseID, Code FROM Question WHERE (UserID = #userid) AND (Code = #code)">
<SelectParameters>
<asp:QueryStringParameter Name="code" QueryStringField="code" />
<asp:SessionParameter Name="userid" SessionField="userid" />
</SelectParameters>
</asp:SqlDataSource>
</body>
the following will do what you want.
Working FIDDLE here
first, change your current divs to give each row a class name we can pick out in our script, like "randomDiv". We could have used "row" but i was afraid you were using that in more places than just these divs.
<div id="NUMBER1" runat="server" class="row randomDiv">
then on document ready run the following javascript:
<script>
$(document).ready(function() {
var divs= $(".randomDiv");
for(var i = 0; i < divs.length; i++){
var target = Math.floor(Math.random() * divs.length -1) + 1;
var target2 = Math.floor(Math.random() * divs.length -1) +1;
divs.eq(target).before(divs.eq(target2));
}
});
</script>

Set values always customized to gridview in asp.net c#

need to fill a gridview via code (C#) and want to know how I define the values ​​for components declared inside of it, like labels, buttons and linkbuttons.
Below is an example of a component that would fill and I'm not getting:
<asp:Label ID="lbCodigo" CssClass="label label-inverse" runat="server" Text='<%#Eval("CODIGO") %>'></asp:Label>
Below is the complete gridview:
<asp:GridView ID="gridContatos" runat="server" AutoGenerateColumns="False" Width="100%" OnRowCommand="gridContatos_RowCommand" OnRowDataBound="gridContatos_RowDataBound" CssClass="table table-condensed" BorderWidth="1px" CellPadding="3" GridLines="Vertical">
<AlternatingRowStyle BackColor="#c0c0c0" />
<Columns>
<asp:TemplateField HeaderText="CAIXA DE ENTRADA - FALE CONOSCO">
<ItemTemplate>
<div class="container">
<div class="row-fluid">
<div class="span2">
<div class="">
<div class="alert label-inverse">
<asp:Label ID="lblbAutor" CssClass="label label-info" runat="server" Text='<%#Eval("NOME") %>'></asp:Label>
</div>
</div>
</div>
<div class="span7">
<div class="">
<div class="alert label-inverse">
<asp:Label ID="lbAssunto" CssClass="label label-success" runat="server" Text='<%#Eval("ASSUNTO") %>'></asp:Label>
</div>
</div>
</div>
<div class="span3">
<div class="alert label-inverse">
<asp:LinkButton ID="lbVisualizar" CssClass="label label-success" Visible="true" runat="server" Text="VER" ToolTip="Responder" CommandName="Visualizar" CommandArgument='<%# Container.DataItemIndex%>' />
<%--<asp:ImageButton ID="imgVisualizar" runat="server" ImageUrl="~/Images/zomin_128x128.png" Width="20px" Height="25%" ToolTip="Responder" CommandName="Visualizar" CommandArgument='<%# Container.DataItemIndex%>' />--%>
<asp:LinkButton ID="lbResponder" runat="server" CssClass="label label-inverse" ToolTip="Responder" Visible="true" Text="RESPONDER" CommandName="Responder" CommandArgument='<%# Container.DataItemIndex%>' />
<asp:LinkButton ID="lbExcluir" runat="server" CssClass="label label-warning" Visible="true" Text="EXCLUIR" ToolTip="Excluir" CommandName="Excluir" CommandArgument='<%# Container.DataItemIndex%>' />
</div>
</div>
</div>
</div>
<br />
<asp:Panel ID="pnMensagem" runat="server" CommandArgument='<%# Container.DataItemIndex%>' Visible=" false">
<hr />
<div class="container">
<div class="row">
<div class="span4">
<div class="caption">
<asp:Label ID="lbCodigo" CssClass="label label-inverse" runat="server" Text='<%#Eval("CODIGO") %>'></asp:Label>
<br />
<asp:Label ID="lbData" CssClass="label label-inverse" runat="server" Text='<%#Eval("DATAENVIO") %>'></asp:Label>
<br />
<asp:Label ID="lbEmail" CssClass="label label-inverse" runat="server" Text='<%#Eval("EMAIL") %>'></asp:Label>
<br />
<asp:Label ID="lbTelefone" CssClass="label label-success" runat="server" Text='<%#Eval("TELEFONE") %>'></asp:Label>
<br />
<asp:Label ID="lbEndereco" CssClass="label label-success" runat="server" Text='<%#Eval("ENDERECO") %>'></asp:Label>
<br />
<asp:Label ID="lbCidade" CssClass="label label-success" runat="server" Text='<%#Eval("CIDADE") %>'></asp:Label>
<%-- <br />
<asp:Label ID="lbCelular" CssClass="label label-inverse" runat="server" Text='<%#Eval("celular") %>'></asp:Label>--%>
</div>
</div>
<div class="span8">
<div class="caption">
<asp:TextBox Width="95%" ID="txtMensagem" runat="server" Text='<%#Eval("MENSAGEM") %>' Enabled="false" TextMode="MultiLine"
Rows="5"></asp:TextBox>
</div>
</div>
</div>
</div>
</asp:Panel>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle />
<HeaderStyle />
<PagerStyle HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle />
<SortedAscendingHeaderStyle />
<SortedDescendingCellStyle />
<SortedDescendingHeaderStyle />
</asp:GridView>
I did not understood your question well but i hope this is what you are asking for .
<asp:Label ID="lbCodigo" CssClass="label label-inverse" runat="server" Text='<%#Bind("CODIGO") %>'></asp:Label>

Categories