<bimsa:GridViewBase ID="gridYorum" runat="server" KeyFieldName="Id" ClientInstanceName="gridYorumClient" OnCustomButtonCallback="StatuGuncelleCallBack"
KaynakKodu="0" Width="100%" OnCustomCallback="grid_CustomCallback" >
<ClientSideEvents EndCallback="function(s, e) {
}" />
<Columns>
<bimsa:DataColumn FieldName="Statu" Visible="false" ></bimsa:DataColumn>
<bimsa:DataColumn FieldName="Yorum" Width="430px" Caption="<%$Resources: Controls, Yorum %>" VisibleIndex="1"></bimsa:DataColumn>
<bimsa:DataColumn FieldName="OlusturanKullanici" Width="100px" Caption="<%$Resources: Controls, YorumSahibi %>" VisibleIndex="2" ></bimsa:DataColumn>
<bimsa:DateTimeColumn FieldName="OlusturmaZamani" Width="100px" Caption="<%$Resources: Controls, YorumZamani %>" VisibleIndex="3" ></bimsa:DateTimeColumn >
<bimsa:CommandColumn KaynakKodu="123">
<CustomButtons>
<bimsa:CustomButton ID="statuGuncelle" Text="Okundu Yap / Okunmadı Yap">
</bimsa:CustomButton>
</CustomButtons>
</bimsa:CommandColumn>
</Columns>
I have a custom button which id's is statuGuncelle and when I click it, I want to change text on this button using this event
c#
protected void StatuGuncelleCallBack(object sender, ASPxGridViewCustomButtonCallbackEventArgs e)
{
BIMSA.Web.UI.Controls.GridViewBase grd = (BIMSA.Web.UI.Controls.GridViewBase)sender;
var key=grd.GetRowValues(e.VisibleIndex, grd.KeyFieldName);
...................
i have fixed problem to use this code.
gridYorum.CustomButtonInitialize += new ASPxGridViewCustomButtonEventHandler(gridYorum_CustomButtonInitialize);
void gridYorum_CustomButtonInitialize(object sender, ASPxGridViewCustomButtonEventArgs e)
{
String statu = gridYorum.GetRowValues(e.VisibleIndex, "Statu").ToString();
if (statu == "Okundu")
{
e.Text = "Okunmadı yap";
}
}
Related
I want to check multiple item checkboxes without clicking on the checkbox, rather than on other clicking columns.
Here is my **.cs code
private void gridView2_RowClick(object sender,DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
{
if (gridView2.GetSelectedRows().Count() > 0)
{
foreach (int i in gridView2.GetSelectedRows())
{
gridView2.SelectRow(i);
}
}
}
And, this is my **.designer.cs code
this.gridView2.OptionsSelection.MultiSelect = true;
this.gridView2.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect;
this.gridView2.OptionsSelection.ShowCheckBoxSelectorInGroupRow = DevExpress.Utils.DefaultBoolean.True;
Ok, assuming a gridview?
We have this markup:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ID" CssClass="table table-hover" OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:BoundField DataField="FirstName" HeaderText="FirstName" />
<asp:BoundField DataField="LastName" HeaderText="LastName" />
<asp:BoundField DataField="HotelName" HeaderText="HotelName" />
<asp:BoundField DataField="City" HeaderText="City" />
<asp:TemplateField HeaderText="Check Test" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" OnClick="MyCheckBoxClick(this);"/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<script>
function MyRowCheck(ctrl) {
MyCheckBox = document.getElementById(ctrl);
MyCheckBox.checked = !MyCheckBox.checked
}
function MyCheckBoxClick(ct) {
ct.checked = !ct.checked
}
</script>
code to load:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
LoadGrid();
}
}
void LoadGrid()
{
using (SqlCommand cmdSQL = new SqlCommand("SELECT TOP 12 * from tblHotels ORDER BY HotelName",
new SqlConnection(Properties.Settings.Default.TEST3)))
{
cmdSQL.Connection.Open();
GridView1.DataSource = cmdSQL.ExecuteReader();
GridView1.DataBind();
}
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
CheckBox MyCheckBox = (CheckBox)e.Row.FindControl("CheckBox1");
e.Row.Attributes["onclick"] = "MyRowCheck('" + MyCheckBox.ClientID + "');";
}
}
So, we just attach a ROW click to the grid.
We get this output:
this works fine and a click on the row will toggle the check box.
but, the PROBLEM is then if you actually click on the check box. The Row click fires toggles the check box, and then the check box click ALSO fires and un-does what you just did!!
So, I added the on-click event to the check box - and we just toggle the setting again, and we are good to go.
I want to remove templatefield from gridview during pageload or before databind to GridView. I have 2 data sources for retrieving data. The data retrieved from one of the data sources do not have the columns ExpireDate and ExpireDays.
So I want to delete the templatefields corresponding to ExpireDate and ExpireDays if the GridView is populated from the data source that do not have those 2 fields.
Setting the visibility to false still will have error of DataRowView doesn't contain property name ExpireDate and ExpireDays.
Markup
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowCommand="GridView1_RowCommand" OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:BoundField DataField="ID" HeaderText="No."/>
<asp:BoundField DataField="Name" HeaderText="Name"/>
<asp:BoundField DataField="CourseName" HeaderText="Course Enroll" />
<asp:BoundField DataField="SubMember" HeaderText="ChildMember" />
<asp:TemplateField HeaderText="Expiry Days">
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:Label runat="server" ID="expDsL" Text=' <%# Eval("ExpiryDays") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Expiry On">
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:Label runat="server" ID="expDeL" Text=' <%# Eval("ExpiryDate") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Function">
<ItemStyle HorizontalAlign="Center" Width="100px"></ItemStyle>
<ItemTemplate>
<asp:ImageButton ImageUrl="~/Images/editB.gif" ID="btnEdit" runat="server" ToolTip="Edit" CommandName="Edit" CommandArgument='<%# Eval("ID") %>' />
<asp:ImageButton ImageUrl="~/Images/delB.gif" ID="btnDelete" runat="server" ToolTip="Delete" CommandName="Delete" CommandArgument='<%# Eval("ID") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Code Behind
protected void Page_Load(object sender, EventArgs e)
{
if(Class.ToLower() != "classAA")
{
// using naveen answer can remove the column.
var expiryDateF = ((DataControlField)GridView1.Columns.Cast<DataControlField>().Where(fid => fid.HeaderText == "Expiry Days").SingleOrDefault());
var expiryDaysF = ((DataControlField)GridView1.Columns.Cast<DataControlField>().Where(fid => fid.HeaderText == "Expiry On").SingleOrDefault());
if (expiryDateF != null)
{
GridView1.Columns.Remove(expiryDateF);
}
if (expiryDaysF != null)
{
GridView1.Columns.Remove(expiryDaysF);
}
}
if(!this.IsPostBack)
{
BindData();
}
}
protected void SaveMember(object sender, EventArgs e)
{
//getting member information and perform checking.
bool success = dbbb.AddMem(memberdetails);
if(success == true)
{
BindData();
}
else
{
//prompt fail message.
}
}
protected void BindData()
{
DataTable dt = dbbb.RetrieveList();
if(dt != null)
{
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
ImageButton btnDel = (ImageButton)e.Row.FindControl("btnDelete");
btnDel.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this member?')");
}
}
How could I delete the column?
Two methods to achieve this
Method 1 - Remove by Index
if(!table.Columns.Contains("CustomerID1"))
{
//seven is the column index here. ie, 8th column
CustomersGrid.Columns.RemoveAt(7);
}
Method 2 - Remove using Columns Header Text
var expiryDateField= ((DataControlField)CustomersGrid.Columns
.Cast<DataControlField>()
.Where(fld => fld.HeaderText == "Expiry Date")
.SingleOrDefault());
if(expiryDateField != null)
{
CustomersGrid.Columns.Remove(expiryDateField);
}
Please not that
CustomersGrid is the name of the asp:GridView here.
table is the DataTable that acts as the DataSource of the GridView
The code should be called before DataBind of the GridView
Attach to the rowDataBound event of the grid, there you can set it dynamically.
You have to know the datasource name of the field you want to hide,
for example the headertext for the cell is "SomeHeader", but the databoundfield name for that cell is
"SomeOtherName"
then you have to check it like this (debug through GetColumnIndexByName) and
check the value of
((BoundField)cell.ContainingField).DataField
int GetColumnIndexByName(GridViewRow row, string columnName)
{
int columnIndex = 0;
foreach (DataControlFieldCell cell in row.Cells)
{
if (cell.ContainingField is BoundField)
if (((BoundField)cell.ContainingField).DataField.Equals(columnName))
break;
columnIndex++; // keep adding 1 while we don't have the correct name
}
return columnIndex;
}
remember that the code above will use a BoundField... then use it like:
protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
int index = GetColumnIndexByName(e.Row, "SomeOtherName");
string columnValue = e.Row.Cells[index].Text;
}
}
i have checkboxes in a grid. I am trying to access them from codebehind and get the data for checked /unchecked rows.But even after the checkboxes being checked I am getting them as Checked property as false only:
Aspx:
<table width="100%">
<asp:GridView ID="grdRequestsPending" runat="server" Width="100%" AutoGenerateColumns="false"
BorderWidth="1px" BorderStyle="Solid" Style="margin-left: 0px" BorderColor="#ffcc00"
RowStyle-BorderColor="#ffcc00" RowStyle-BorderStyle="Solid" RowStyle-BorderWidth="1px"
GridLines="Both" DataKeyNames="ReqID,ApproverComments" On="grdRequestsPending_ItemDataBound" OnRowDataBound="grdRequestsPending_RowDataBound"
OnPreRender="grdRequestsPending_PreRender">
<RowStyle CssClass="dbGrid_Table_row" />
<HeaderStyle CssClass="dbGrid_Table_Header" />
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:Label ID="lblSelect" Text="Select All" runat="server"></asp:Label><br />
<asp:CheckBox ID="SelectAll" onclick="javascript:checkAllBoxes(this);" TextAlign="Left"
runat="server" />
</HeaderTemplate>
<ItemStyle Width="2%" />
<ItemTemplate>
<asp:CheckBox ID="chkReq" runat="server"/>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" Width="7%" />
</asp:TemplateField>
</Columns>
But when I am checking these I am always getting them as false in code behind:
protected void UpdateVMRequestStatusByCapSupLead(int StatusId)
{
try
{
DataTable dt = new DataTable();
dt.Columns.Add("ReqId", typeof(int));
dt.Columns.Add("StatusId", typeof(int));
dt.Columns.Add("ModifiedBy", typeof(string));
dt.Columns.Add("ModifiedDate", typeof(string));
dt.Columns.Add("txtCommentSupLead", typeof(string));
foreach (GridViewRow gr in grdRequestsPending.Rows)
{
CheckBox chk = (CheckBox)gr.FindControl("chkReq");
if (chk.Checked)
{
strReqId = strReqId + grdRequestsPending.DataKeys[gr.RowIndex].Value.ToString() + ',';
TextBox txtCommentSupLead = (TextBox)gr.FindControl("txtCommentSupLead");
dt.Rows.Add(dt.NewRow());
dt.Rows[dt.Rows.Count - 1]["ReqId"] = Convert.ToInt32(grdRequestsPending.DataKeys[gr.RowIndex].Value);
dt.Rows[dt.Rows.Count - 1]["StatusId"] = StatusId;
dt.Rows[dt.Rows.Count - 1]["ModifiedBy"] = Session["UserAccentureID"].ToString();
dt.Rows[dt.Rows.Count - 1]["txtCommentSupLead"] = txtCommentSupLead.Text;
dt.Rows[dt.Rows.Count - 1].AcceptChanges();
dt.Rows[dt.Rows.Count - 1].SetModified();
}
}
I am not getting the problem.I am gettign the control also correctly..
I assume that you're always databinding your GridView and not only if(!Page.IsPostBack)....
So put this in page_load
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
DataBindControls(); // like GridView etc.
}
}
If you DataBind controls they will lose their changes and ViewState. Even events aren't triggered then. So you should do that only on the first load if EnableViewState="true".
Here is a simple example of populating a checkbox in a gridview and getting the values out on a button click
Default.aspx
<asp:GridView ID="gv"
runat="server"
AutoGenerateColumns="false"
OnRowDataBound="gv_RowDataBound">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="chkReq" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<asp:Button ID="btnSubmit"
runat="server"
OnClick="btnSubmit_Click"
Text="Submit" />
Default.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//Create 20 rows
gv.DataSource = Enumerable.Range(1, 20);
gv.DataBind();
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
var isCheckedList = new List<bool>();
for(var index = 0; index < gv.Rows.Count; ++index)
{
var chkReq = (CheckBox)gv.Rows[index].FindControl("chkReq");
isCheckedList.Add(chkReq.Checked);
}
//Look at isCheckedList to get a list of current values.
System.Diagnostics.Debugger.Break();
}
protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
var index = e.Row.RowIndex;
//Strongly Bind Controls
var chkReq = (CheckBox)e.Row.FindControl("chkReq");
chkReq.Text = "Item " + index.ToString();
}
}
Since you did not show all of your code, it could be an issue like Tim Schmelter said or it could be something else. This example provides you with the basics that are needed to retrieve a checkbox value from a grid view.
Why is that I need to click the edit link twice, in a gridview control, before my row enters into edit mode?
<asp:ObjectDataSource ID="ods" runat="server" TypeName="Employee"
SelectMethod="GetAll" ></asp:ObjectDataSource>
<asp:GridView ID="GridView1" runat="server" CssClass="styled"
OnRowCommand="gv_RowCommand" DataSourceID="ods"
OnSorting="gv_Sorting" >
<Columns>
...........
</Columns>
<ItemTemplate>
<ItemTemplate>
<div class='actions'>
<asp:Button ID="btnEdit" runat="server" Text=" Edit " ToolTip="Edit Row" CommandName="Edit" CommandArgument='<%# DataBinder.Eval(Container.DataItem,"Id") %>' CausesValidation="False" />
<span style="padding-left:10px"></span>
</div>
</ItemTemplate>
</asp:GridView>
protected override void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
this.ods.SelectParameters[0].DefaultValue = "";
}
}
protected void gv_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == CRUID.Edit.ToString())
{
this.gv.ShowFooter = false;
}
}
You need to avoid rebinding your gridview on each postback.
If not ispostback then
GridView1.DataSource = dt
GridView1.DataBind()
end if
Otherwise you just overwrite Gridview changes.
Great explanation at this link...
http://www.pcreview.co.uk/forums/gridview-two-clicks-needed-enter-place-editing-t3328887.html
Try handling the RowEditing event to set the EditItem Index:
protected void gv_RowEditing(object sender, GridViewEditEventArgs e)
{
gv.EditIndex = e.NewEditIndex
}
There are some mistakes in your code as i examined. Correct your code as shown below:
<asp:ObjectDataSource ID="ods" runat="server" TypeName="Employee"
SelectMethod="GetAll" ></asp:ObjectDataSource>
<asp:GridView ID="GridView1" runat="server" CssClass="styled"
OnRowCommand="gv_RowCommand" DataSourceID="ods"
OnSorting="gv_Sorting" >
<Columns>
...........
<asp:TemplateField>
<ItemTemplate>
<div class='actions'>
<asp:Button ID="btnEdit" runat="server" Text=" Edit " ToolTip="Edit Row" CommandName="Edit" CommandArgument='<%# DataBinder.Eval(Container.DataItem,"Id") %>' CausesValidation="False" />
<span style="padding-left:10px"></span>
</div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
protected override void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
this.ods.SelectParameters[0].DefaultValue = "";
}
}
protected void gv_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Edit")
{
this.gv.ShowFooter = false;
}
}
If on using this code the problem does not solve then there may be some problem in your cssclass which you used with your GridView as I have Checked your code on my machine using ObjectDataSource and it works well using edited code.
Also I want to know that what is CRUID in CRUID.Edit.ToString()
and why you used the following line in Page_Load event
this.ods.SelectParameters[0].DefaultValue = "";
as there are no parameter associated with your SelectMethod="GetAll" method used in ObjectDataSource.
May this answer help you.
I guess there is some conflict with the updatepanels on your page..
Try removing all your Update Panels and try again.. It will work for sure.. Mine worked a few seconds ago.. so thought It would be good to share..
Yet another problem with DevExpress AspxGridView :)
The context:
One Page
In the Page, a custom control
In the custom Control, a AspxDropDown
The AspxDropDown has a DropDownWindowTemplate
In the DropDownItemTemplate, I add a GridView and a paging/sorting/filtering enabled ObjectDataSource
When handling the selecting event of the ObjectDataSource, I should set filter parameters for the datasource. There filter parameters should come from the FilterRow of the AspxGridView (preferably using the AspxGridView.FilterExpression property).
The problem: the AspxGridView.FilterExpression property is not set to the proper values (set by the user).
Did anyone find a good implementation of what I'm trying to do here?
Thanks a bunch.
:)
I've finally managed to get around the problem.
Not a good solution, but, still, a way to work around it.
So.. The "solution" is to databind the grid on every AfterPerformCallback event.
void grid_AfterPerformCallback(object sender, ASPxGridViewAfterPerformCallbackEventArgs e)
{
((DevExpress.Web.ASPxGridView.ASPxGridView)sender).DataBind();
}
As I've said, it's not a good solution.
The answer per DevExpress is that the correct FilterExpression is updated when it is databound.
They allege that in BeforePerformDataSelect, you will see the correct value.
I have 1 grid that is hooked up to a SqlDataSource that is correctly doing this, and another that is not... So you're mileage may vary.
My second grid wasn't obeying this principal, so I integrated the other guy's concept rebinding in AfterPerformCallback(). The trick is to prevent double querying. This code also demonstrates how to hijack devexpress to build your own SQL. Obviously, this is from my working project, so use your imagination on functions that I have that you don't...
Here is the relevant html and code:
<dxwgv:ASPxGridView ID="grid" runat="server"
KeyFieldName="OrderID"
OnAfterPerformCallback="grid_AfterPerformCallback"
OnBeforePerformDataSelect="grid_BeforePerformDataSelect"
AutoGenerateColumns="True"
SettingsDetail-AllowOnlyOneMasterRowExpanded="true"
Settings-ShowFilterRow="true"
Settings-ShowFilterRowMenu="True"
SettingsBehavior-AllowSelectSingleRowOnly="true"
OnDetailRowExpandedChanged="Grid_DetailRowExpandedChanged"
Styles-Cell-Cursor="pointer"
SettingsBehavior-EnableRowHotTrack="true"
CssFilePath="~/App_Themes/Office2010Blue/{0}/styles.css"
CssPostfix="Office2010Blue"
SettingsPager-PageSize="<%# this._GridRowsPerPage %>"
SettingsBehavior-ColumnResizeMode="Control"
SettingsCustomizationWindow-PopupHorizontalAlign="WindowCenter"
SettingsCustomizationWindow-PopupVerticalAlign="WindowCenter"
SettingsCustomizationWindow-Width="300px"
Settings-ShowHorizontalScrollBar="true"
Width="<%# this._GetWidth() %>"
SettingsPager-AlwaysShowPager="true"
SettingsCookies-Enabled="true"
>
<Columns>
<dxwgv:GridViewDataColumn FieldName="PriorityType" Visible="false" />
<dxwgv:GridViewDataColumn FieldName="basePatientID" Caption="PTID" />
<dxwgv:GridViewDataColumn FieldName="FirstName" />
<dxwgv:GridViewDataColumn FieldName="LastName" />
<dxwgv:GridViewDataColumn FieldName="Employer" />
<dxwgv:GridViewDataColumn FieldName="Insurer" />
<dxwgv:GridViewDataColumn FieldName="ClaimJurisdiction" Caption="Jurisdiction" />
<dxwgv:GridViewDataColumn FieldName="DOB" Visible="false" />
<dxwgv:GridViewDataColumn FieldName="DateOfInjury" Caption="DOI" Visible="false" />
<dxwgv:GridViewDataColumn FieldName="PostalCode" Caption="ZipCode" Visible="false" />
<dxwgv:GridViewDataColumn FieldName="FirstCareDate" Visible="false" />
<dxwgv:GridViewDataColumn FieldName="LastCareDate" Visible="false" />
<dxwgv:GridViewDataColumn FieldName="IntakeStatus" />
<dxwgv:GridViewDataColumn FieldName="SchedulingNeeded" />
<dxwgv:GridViewDataColumn FieldName="InitialReferralDate" Caption="Date Assigned" />
<dxwgv:GridViewDataColumn FieldName="Orders_UpdatedOn" Caption="Last Follow-up" />
<dxwgv:GridViewDataColumn FieldName="RequestTypes" Caption="Service" Visible="false" />
<dxwgv:GridViewDataColumn FieldName="FacilityGroups" Caption="Provider" Visible="false" />
<dxwgv:GridViewDataColumn FieldName="ICD9Codes" Visible="false" />
<dxwgv:GridViewDataColumn FieldName="CPTCodes" Visible="false" />
<dxwgv:GridViewDataColumn FieldName="OrderCategory" Caption="Source" />
<dxwgv:GridViewDataColumn FieldName="CaseCoordinator" Visible="false" />
<dxwgv:GridViewDataColumn FieldName="SchedulingTier" Visible="false" Caption="Tier" />
<dxwgv:GridViewDataColumn FieldName="LockRequest_UserName" Visible="true" Caption="InUseBy" />
</Columns>
<Styles CssFilePath="~/App_Themes/Office2010Blue/{0}/styles.css" CssPostfix="Office2010Blue">
<Header ImageSpacing="5px" SortingImageSpacing="5px">
</Header>
<LoadingPanel ImageSpacing="10px">
</LoadingPanel>
</Styles>
<ImagesFilterControl>
<LoadingPanel Url="~/App_Themes/Office2010Blue/Editors/Loading.gif">
</LoadingPanel>
</ImagesFilterControl>
<Images SpriteCssFilePath="~/App_Themes/Office2010Blue/{0}/sprite.css">
<LoadingPanelOnStatusBar Url="~/App_Themes/Office2010Blue/GridView/gvLoadingOnStatusBar.gif">
</LoadingPanelOnStatusBar>
<LoadingPanel Url="~/App_Themes/Office2010Blue/GridView/Loading.gif">
</LoadingPanel>
</Images>
<ClientSideEvents ContextMenu="grid_ShowContextMenu" />
<ClientSideEvents BeginCallback="function(s, e) { OnBeginCallback(s,e); }" />
<ClientSideEvents EndCallback="function(s, e) { OnEndCallback(s,e); }" />
<StylesEditors>
<ProgressBar Height="25px">
</ProgressBar>
</StylesEditors>
</dxwgv:ASPxGridView>
<asp:SqlDataSource ID="GridSource" runat="server"></asp:SqlDataSource>
And here's the event handler for BeforePerformDataSelect:
private bool _DataBindingCompleted = false;
protected void grid_BeforePerformDataSelect(object sender, EventArgs e)
{
if (_DataBindCompleted) Grid_PerformDataSelect(sender, e);
}
protected override void Grid_PerformDataSelect(bool ClearSelection)
{
if (ClearSelection) this.grid.Selection.UnselectAll();
GridSource.ProviderName = System.Configuration.ConfigurationManager.ConnectionStrings["mysql"].ProviderName;
GridSource.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["mysql"].ConnectionString;
SetupSearch();
//if (this.FilterContext.Count > 0 || !string.IsNullOrEmpty(grid.FilterExpression))
//{
string FilterSQL = DevExpressUtils.GetMySQLFilterExpression(grid);
string OrderBySQL = DevExpressUtils.GetSQLOrderByExpression(grid, "OrderID");
//FilterSQL = FilterSQL.Replace("[PatientID]", "vwPatients."+ Patient.PRIMARYKEY);
if (Utils.GetAppSettingBool("MYSQL"))
{
GridSource.SelectCommand = this.MP.CurrentUser.GetEOSHeaderSQL(this.FilterContext, FilterSQL, "");
}
else
{
GridSource.SelectCommand = "";
}
}
protected override void Grid_PerformDataSelect(object sender, EventArgs e)
{
bool IsFromParent = this.ClientID.StartsWith(this.MP.GridCallback);
if (grid.Visible && (!this.Page.IsCallback ||
((this.MP.GridCallback == this.grid.ClientID && (this.MP.GridCallbackCommand != "SHOWDETAILROW" || this.IsDetailGrid))
|| (this.MP.GridCallbackCommand == "SHOWDETAILROW" && IsFromParent)
)
)
)
{
Grid_PerformDataSelect(false);
}
}
protected void grid_AfterPerformCallback(object sender, ASPxGridViewAfterPerformCallbackEventArgs e)
{
_DataBindCompleted = true;
((DevExpress.Web.ASPxGridView.ASPxGridView)sender).DataBind();
}
protected void Page_Init(object sender, EventArgs e)
{
grid.DataSource = GridSource;
}
protected new void Page_Load(object sender, EventArgs e)
{
this.grid.ClientInstanceName = this.grid.ClientID;
if (!this.IsPostBack)
{
_DataBindCompleted = true;
grid.DataBind();
}
}