html button text not changing when gridview OnSelectedIndexChanged fired - c#

After clicking the edit button of gridview btnSaveClass.text text change as expected but on the other hand btnSave.text text not changing
I have debugged certain portion of the code. And find that it's taking the changed text btnSave.InnerText = "Update"; in this line. But some how it loose the data. And some how it becomes same as it was.
//==========================================================This is The Markup=============================
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div class="col-md-4 col-sm-4 col-xs-12 form-group item margin">
<input type="text" class="form-control has-feedback-left" id="txtFName" maxlength="20" onkeypress="return isNameKey(event,this)" required="required" runat="server" placeholder="First Name" />
<span class="fa fa-user form-control-feedback left" aria-hidden="true"></span>
</div>
<div class="col-md-4 col-sm-4 col-xs-12 form-group item margin">
<input type="text" class="form-control has-feedback-left" id="txtLName" onkeypress="return isNameKey(event,this)" required="required" runat="server" maxlength="20" placeholder="Last Name" />
<span class="fa fa-user form-control-feedback left" aria-hidden="true"></span>
</div>
<div class="col-md-4 col-sm-4 col-xs-12 form-group item margin">
<input type="text" class="form-control has-feedback-left" id="txtConNumber" onkeypress="return isNumberKey(event,this)" maxlength="11" required="required" runat="server" placeholder="Contact Number" />
<span class="fa fa-mobile form-control-feedback left" aria-hidden="true"></span>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<div class="ln_solid"></div>
<div class="form-group ">
<div class="col-md-6 margin ">
//===================================================This button text not changing======================
<button type="button" id="btnSave" runat="server" class="btn btn-success" onserverclick="btnSaveOnClick">Save</button>
<button id="Button2" runat="server" type="button" class="btn btn-primary" onserverclick="btnRefreshOnClick">Refresh</button>
</div>
</div>
<div class="col-md-3 col-sm-3 col-xs-12 form-group item">
<asp:TextBox ID="txtRegInfo" required="required" CssClass="form-control has-feedback-left" placeholder="Student Official Id" MaxLength="50" runat="server"></asp:TextBox>
<span class="fa fa-registered form-control-feedback left" aria-hidden="true"></span>
</div>
<div class="col-md-3 col-sm-3 col-xs-12 form-group item " style="position: relative;">
<asp:UpdatePanel ID="UpdatePa" runat="server">
<ContentTemplate>
<div class="col-md-12 col-sm-12 col-xs-12 form-group item" style="margin: 0px; padding: 0px;" id="DivddlClassName" runat="server">
<asp:DropDownList ID="ddlClassName" runat="server" CssClass="col-md-12 form-control item has-feedback-left" AutoPostBack="true" OnSelectedIndexChanged="ddlClassNameOnSelectedIndexChanged">
</asp:DropDownList>
<span class="fa fa-tasks form-control-feedback left" aria-hidden="true"></span>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div class="col-md-3 col-sm-3 col-xs-12 form-group item">
<asp:TextBox ID="txtClassRoll" required="required" onkeypress="return isNumberKey(event,this)" MaxLength="5" CssClass="form-control has-feedback-left" placeholder="Class Roll" runat="server"></asp:TextBox>
<span class="fa fa-star form-control-feedback left" aria-hidden="true"></span>
</div>
<div class="col-md-3 col-sm-3 col-xs-12 form-group item">
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<div class="col-md-12 col-sm-12 col-xs-12 form-group item" style="margin: 0px; padding: 0px;" id="ddlSectionDiv" runat="server">
<asp:DropDownList ID="ddlSection" runat="server" CssClass="col-md-12 form-control item has-feedback-left" AutoPostBack="true">
<asp:ListItem Value="0" Text="Select A Section"></asp:ListItem>
<asp:ListItem Value="1" Text="A"></asp:ListItem>
<asp:ListItem Value="2" Text="B"></asp:ListItem>
<asp:ListItem Value="3" Text="C"></asp:ListItem>
<asp:ListItem Value="4" Text="D"></asp:ListItem>
<asp:ListItem Value="5" Text="E"></asp:ListItem>
<asp:ListItem Value="6" Text="F"></asp:ListItem>
</asp:DropDownList>
<span class="fa fa-list-alt form-control-feedback left" aria-hidden="true"></span>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div class="clearfix"></div>
<div class="col-md-3 col-sm-3 col-xs-12 form-group item">
<asp:UpdatePanel ID="UpdatePanel4" runat="server">
<ContentTemplate>
<div class="col-md-12 col-sm-12 col-xs-12 form-group item" style="margin: 0px; padding: 0px;" id="ddlShiftNameDiv" runat="server">
<asp:DropDownList ID="ddlShiftName" runat="server" CssClass="col-md-12 form-control item has-feedback-left" AutoPostBack="true">
<asp:ListItem Value="0" Text="Select A Shift"></asp:ListItem>
<asp:ListItem Value="1" Text="Morning"></asp:ListItem>
<asp:ListItem Value="2" Text="Day"></asp:ListItem>
<asp:ListItem Value="3" Text="Evening"></asp:ListItem>
</asp:DropDownList>
<span class="fa fa-list-alt form-control-feedback left" aria-hidden="true"></span>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<div class="form-group ">
<div class="col-md-6 ">
//==========================================================================This button text changed as expected==============================================
<button type="button" data-target="#myModal" class="btn btn-success" id="btnSaveClass" runat="server" onserverclick="btnSaveClassInfoOnClick">Save</button>
<button id="btn" runat="server" type="button" class="btn btn-primary" onserverclick="btnRefreshOnClick">Refresh</button>
</div>
</div>
//========================================================================This is the gridview===============================
<asp:UpdatePanel ID="UpdatePanel5" runat="server">
<ContentTemplate>
<div class="col-md-12 text-center" style="padding: 10px; background-color: red; color: white; font-weight: bold" id="lblMsg" runat="server" visible="false">One Row has Deleted</div>
<asp:GridView ID="GvStudentIformation" runat="server" Width="100%" CssClass="table table-striped table-bordered table-hover jambo_table bulk_action"
AutoGenerateColumns="False" DataKeyNames="StdntID" AllowPaging="True" OnPageIndexChanging="GvStudentIformationOnPageIndexChanged"
OnRowDeleting="GvStudentInfoOnRowDeleting" OnSelectedIndexChanged="GvStudentInfoOnSelectedIndexChanged">
<HeaderStyle HorizontalAlign="Center" ForeColor="White" BackColor="#3F5367"></HeaderStyle>
<RowStyle CssClass="even pointer " HorizontalAlign="Center" BackColor="#E9F4F2"></RowStyle>
<Columns>
<asp:BoundField DataField="RegistrationNo" ItemStyle-HorizontalAlign="Center" HeaderText="Registration No"></asp:BoundField>
<asp:BoundField DataField="FullName" ItemStyle-HorizontalAlign="Center" HeaderText="Name"></asp:BoundField>
<asp:BoundField DataField="StdntID" HeaderText="Student Class Id">
<ItemStyle CssClass="hidden" />
<HeaderStyle CssClass="hidden" />
</asp:BoundField>
<asp:BoundField DataField="FirstName" HeaderText="First Name">
<ItemStyle CssClass="hidden" />
<HeaderStyle CssClass="hidden" />
</asp:BoundField>
<asp:BoundField DataField="LastName" HeaderText="Last Name">
<ItemStyle CssClass="hidden" />
<HeaderStyle CssClass="hidden" />
</asp:BoundField>
<asp:BoundField DataField="StdntClassID" HeaderText="Student Class Id">
<ItemStyle CssClass="hidden" />
<HeaderStyle CssClass="hidden" />
</asp:BoundField>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderText="Delete">
<ItemTemplate>
<asp:LinkButton ID="ButtonDelete" runat="server" CausesValidation="False" CommandName="Delete"><img src="../../images/delete.png" /></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField HeaderText="Edit" ShowSelectButton="true" ButtonType="Image" SelectImageUrl="~/images/Edit.png" ItemStyle-Height="5px" ItemStyle-HorizontalAlign="Center"></asp:CommandField>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderText="Details">
<ItemTemplate>
<asp:HyperLink ID="btnDetails" runat="server" CausesValidation="False" ForeColor="black" NavigateUrl='<%# String.Format("../Admission/StudentDetails.aspx?StdntID={0}&StdntClassID={1}", Eval("StdntID"), Eval("StdntClassID")) %>'><i class="fa fa-eye"></i> Details</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<SelectedRowStyle BackColor="#CFF0E9" Font-Bold="True" ForeColor="#333333" BorderColor="#1ABC9C" />
<HeaderStyle BackColor="#3F5367" Font-Bold="True" ForeColor="White" HorizontalAlign="Left" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="white" />
<PagerStyle HorizontalAlign="Left" ForeColor="#3F5367" CssClass="gvPagers pad" />
<PagerSettings Mode="NumericFirstLast" PageButtonCount="4" FirstPageText="First" LastPageText="Last" />
<EmptyDataTemplate>
<div class="text-center">No records found.</div>
</EmptyDataTemplate>
</asp:GridView>
<asp:HiddenField ID="HdfstdId" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
//===========Here is the problem, First button text not changing but Second Button Text Changes as Expected=================
protected void GvStudentInfoOnSelectedIndexChanged(object sender, EventArgs e)
{
string id = GvStudentIformation.SelectedRow.Cells[0].Text.Trim().Replace(" ", "");
HdfstdId.Value = id;
txtFName.Value = GvStudentIformation.SelectedRow.Cells[3].Text.Trim().Replace(" ", "");
txtLName.Value = GvStudentIformation.SelectedRow.Cells[4].Text.Trim().Replace(" ", "");
btnSave.InnerText = "Update";
btnSaveClass.InnerText = "Update";
}

Exactly I used script for changing button Text. And that solved the issue.
function ButtonTextChange() {
document.getElementById('<%=btnInfoSave.ClientID %>').innerText = "Update";
}
Here I call The funtion.
ScriptManager.RegisterStartupScript(this, this.GetType(), "CallMyFunction", "ButtonTextChange();", true);

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>

Insert data quarterly into SQL Server table from 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

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