I want to show a button on select of a Grid row , I am using RowSelectionChanged event to enable the button .when i debug on my local the event is fired immediately but which should enable the button on the page ... but my button is still disabled.
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { DataTable dt = new DataTable(); dt.Clear(); dt.Columns.Add("Name"); dt.Columns.Add("Address"); object[] o = { "abhi", "USA" }; object[] o1 = { "arjun", "USA" }; object[] o2 = { "vijaya", "USA" }; dt.Rows.Add(o); dt.Rows.Add(o1); dt.Rows.Add(o2); Grid.ClearDataSource(); Grid.DataSource = dt; Grid.DataBind(); EditButton.Enabled = false; } } protected void Grid_RowSelectionChanged(object sender, SelectedRowEventArgs e) { EditButton.Enabled = true; }
<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager>
<ig:WebDataGrid ID="Grid" runat="server" EnableAppStyling="False" EnableAjax="True" EnableAjaxViewState="true" Height="150px" EnableDataViewState="True" AutoGenerateColumns="False" OnRowSelectionChanged="Grid_RowSelectionChanged" > <Columns> <ig:BoundDataField DataFieldName="Name" Key="Name" Width="200px" HtmlEncode="False"> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Address" Key="Address" Width="200px" DataFormatString=""> </ig:BoundDataField> </Columns> <Behaviors> <ig:Selection Enabled="true" RowSelectType="Single" CellClickAction="Row"> <AutoPostBackFlags RowSelectionChanged="True" ></AutoPostBackFlags> </ig:Selection> </Behaviors> </ig:WebDataGrid> <asp:Button runat="server" ID="EditButton" Text="EDIT"/>
Hello,I am still following your case. Have you been able to resolve the issue using the suggested ?If you have any concerns or questions, please feel free to contact me, I will be glad to help you.Thank you for choosing Infragistics components!
Hello Arjun,
I suggest that you keep the EnableAjax = true property of the grid and keep your logic in the server RowSelectionChanged event. Then it is possible to use the AJAXResponse property of the grid - it sets the name of javascript function which is called after the control gets AJAX response (the response of the logic you implement in the RowSelectionChanged event) from the server. In this javascript function you can change the button state:
I believe this fits your scenario and will keep your grid's performance. Please test in on your side and let me know if it meets your requirements.
with Ajax= true , since the button status was not changed( with ajax true) it really made no difference in the page for me.
now when i use ajax false, the page is posting back , i can see button status change based on grid column value but it kind of not that fast .
Logic: Based on a grid column value , i will run a services to get the status of the records ,based on what the status is ( i have set of three button) i will need to enabe/diable webimagebuttion
PS: i am using webimagebutton itself.
It is hard to say what is the best approach in this case. Would you please clarify what is your scenario and what is the logic you need to perform on RowSelectionChanged server side event. Is it slow performing when you set the EnableAjax = true ?
1) It seems you cannot do this.
2) Yes, you can handle the client side rowselectionchanged event and trigger a postback in this event like this:
function WebDataGrid1_Selection_RowSelectionChanged(sender, eventArgs) { if (eventArgs.getSelectedRows().get_length() > 0) { __doPostBack('<%= WebDataGrid1.ClientID %>', ''); } }
.....
<ig:Selection CellClickAction="Row" RowSelectType="Single"> <SelectionClientEvents RowSelectionChanged="WebDataGrid1_Selection_RowSelectionChanged" /> </ig:Selection>
However this would not make any difference.
It would really help if you send your sample demonstrating this behavior so that I will be able to provide more insight.
In the meantime you can also check http://help.infragistics.com/Help/Doc/ASPNET/2014.1/CLR4.0/html/WebDataGrid_Events.html
Thank you so much. This seems to have worked but like i said i have lot of logic to be performed on each row selectionchanged and page is letting you select a different record even before the the previous selection post back response appeared. thus making it poor performing.
1)is there a way to freeze the selection until we get the response from the previus selection row change event ?
2) Can we call the server method on the client side event ? will it improve any performance.