Forms Data Controls :: Get The DataSource Of GridView Control In SelectedIndexChanged Event Handler?

Jun 8, 2010

Get the DataSource of GridView control in SelectedIndexChanged event handler?

View 6 Replies

Similar Messages:

Forms Data Controls :: Get Row Data In SelectedIndexChanged Handler For Dropdown Nested In GridView

Aug 2, 2010

I have a GridView, with a DropDownList as one of the Columns. I can get the SelectedIndexChanged method to trigger - but I cannot figure out how to get other Data regarding which row this triggered on i.e. if I could get the value in the ID column (DocID below), that would be great. My code is a bit too long, so I am just posting snippets. In the *.aspx file I have:


In the *.aspx.cs File:


I am wondering if I can get the DocID from within StatusDropDownList_SelectedIndexChanged - so that I can make appropriate changes to the Database. For e.g. in the RowDataBound event, which I had a GridViewRowEventArgs e, I could easily do e.Row.DataItem - to get the DataItem, I am wondering if I get/do something similar in the SelectedIndexChanged method. (I would prefer this be not the GridView Row Index i.e. I would prefer the DataItem if possible.)

View 3 Replies

Forms Data Controls :: SelectedIndexChanged Event Does Not Fire When Binding DataSource To ListView

Mar 5, 2010

I'm using VS2008. When a dataset is bound to the DataSource of a ListView, SelectedIndexChanged event does not fire. If I used DataSourceID instead, it has no problem. But SelectedIndexChanging event fires for both.

why and how I can get SelectedIndexChanged event fired when DataSource is used?

View 9 Replies

Web Forms :: Common SelectedIndexChanged Event Handler For Multiple RadioButtonList

May 20, 2013

If I have 10 radio button and the value of ten is same 1,0, 2

<asp:RadioButtonList ID="rd_12_a" runat="server" onclick="" RepeatDirection="Horizontal">
<asp:ListItem Value="1">Yes/asp:ListItem>
<asp:ListItem Value="0">no</asp:ListItem>
<asp:ListItem Value="2">other</asp:ListItem>

So instead of writing if condition for all can i write like this

radiobuttonlist rbl =(radiobuttonlist)sender;
if (rbl.selectedvalue="1" || rbl.selectedvalue="2")

then the javascript modal pop-up will display a message...

View 1 Replies

Forms Data Controls :: On Dynamic Control The DropDownList SelectedIndexChanged Event Fires Several Times?

Aug 4, 2010

I ask for a date, on OnTextChanged event i bind data with a SqlDataSource to a dropdownlist and also bind data to a repeater passing the dropdownlist SelectedIndex (i use SqlDataSource too and ControlParameter to link the dropdownlist and the repeater) On my repeater during the ItemDataBound event i create dynamic dropdownlist controls, my code is :



On the Page_load event of my page i bind the data & recreate the control :


Everything works fine, datas are bound and SelectedIndexes are restore on every postback.

The probem occurs when user change different dropdownlists, if he choose to change the 1st dropdownlist the event is fire (normal), after if he modifies another dropdownlist the event is fire twice, if he modifies a 3rd time the event is fire 3 time etc...

View 18 Replies

Event Handler - Obtain Selected Data From GridView Control

Jan 26, 2016

I use this code to obtain a selected data from GridView control. I created a user control and reference it to ASPX page. However, for some reason I can not access public methods IndexChanged to retrieve information of selected line.

User controls:
Public gridRow As GridViewRow
Public Event IndexChanged As GridViewSelectEventHandler
Protected Sub GridView_SelectedIndexChanged (sender As Object, e As EventArgs) Handles gv.SelectedIndexChanged
******* gridRow = Grid.SelectedRow
******* RaiseEvent IndexChanged (sender, e)
End Sub

ASPX page:
grid.IndexChanged - there is no such event in the selection (the grid is the name of the user control)

View 3 Replies

Forms Data Controls :: How To Add Event Handler For Selected Row In Gridview Using TemplateField

Feb 24, 2011



I want to add an event handeler that tell me wich row had been selected and highlighted it too. I tried many times, but usually face this error "No overload for 'Grd_ServersInfo_CheckSelectedRow' matches delegate 'System.EventHandler' ". Could any one paste the right code lines to handel this event

View 4 Replies

Forms Data Controls :: Dynamic GridView RowUpdating Event Handler Will Not Run?

Feb 1, 2010

I'm creating a GridView in code. I can successfully attach handlers for Editing, and CancelEditing. RowUpdating never runs, however. Instead, if the GridView is in a Panel, the Edit handler is called when Update is clicked (and this is the command name I get back on the Update click, too). If the GridView is not in a panel, then the Cancel handler is called when Update is clicked (again, this is the command name I get back from clicking Update). I've searched high and low for a reason why the RowUpdating event is not getting called, and I can't find one. Does anyone out there haveHere is my code (My actual code is much more involved than this, but for testing purposes, I extracted the following code and stuck it in a new project to isolate my problem):

protected void Page_Init(object sender, EventArgs e)
if (!IsPostBack)


View 1 Replies

Data Controls :: DropDownList SelectedIndexChanged Event Not Working When Placed Inside GridView Footer

Jan 24, 2016

With ref. to this post, [URL]

I have placed a dropdown list in Gridview footer, now i want to access the dropdown selected indeex changed event as below. But i'm not able to access the event.

protected void ddlCatg_SelectedIndexChanged(object sender, EventArgs e)
DropDownList ddlCategories = grvExpenses.FooterRow.FindControl("ddlCatg") as DropDownList;
DropDownList ddlExpenseSubCategories = grvExpenses.FooterRow.FindControl("ddlSubCatg") as DropDownList;


View 1 Replies

Data Controls :: Prevent SelectedIndexChanged Event To Fire On Checkbox Checked In GridView

Jul 31, 2013

I have a grideview and inside grideview I have check box ,I don't want SelectedIndexChanged grideview event to fire on checkbox checked in GridView.

View 1 Replies

Data Controls :: Apply Discount To GridView Amount On DropDownList SelectedIndexChanged Event?

Oct 15, 2012

i have a gridview in which i have a 3 column serial no, particular , amount .in particular column i have a feild tution fees . and its shows it amount any integer value( like 5000). now i have a dropdown list outside the grid n if i selct any value from that dropdown list . the tution fees will be change on the event of selecting value of drop down list.( say if i select the value 10 then it tution fee will be 4500 , means 10% discount on tution fees) how it will be done?

View 1 Replies

Data Controls :: GridView SelectedIndexChanged Event Error - Argument Out Of Range Exception

Dec 23, 2015

I'm facing error in code behind. It is showing the above exception. Code behind code is as follows


<asp:GridView ID="gv_TPBill" runat="server" AutoGenerateColumns="false" DataKeyNames="Instance Name"
OnRowDataBound="OnRowDataBound" OnSelectedIndexChanged="OnSelectedIndexChanged">
<asp:TemplateField HeaderText="Client Name" ItemStyle-Width="150">


View 1 Replies

Forms Data Controls :: Update A Colums Value Of A Row In A Gridview On Row Command Event Handler?

Aug 11, 2010

How to update a colums value of a Row in a gridview on Row Command Event Handler. I am using a SQL Datasource.


View 5 Replies

Forms Data Controls :: How To Access Attributeid Values In Repeater Control's ItemDataBound Event Handler

Jan 15, 2011

i have simple repeater control on my page:

<asp:Repeater id="Repeater1" runat="server" DataSourceID="SqlDataSource1">
<asp:TextBox id="txtBox1" runat="server" Text='<%#Eval("attributename") %>'></TextBox>

I'm bounding data to repeater control by using SqlDataSource Control

bounded data is something like this:

attributeid attributename
1 color
2 size

How can I get access to attributeid values in Repeater control's ItemDataBound event handler,

I tried to use DataBinder.GetPropertyValue(container,"attribuetid"), but I can't set container, am I doing right, or maybe I should use another approach.

View 2 Replies

Forms Data Controls :: How To Get (code Behind) Event Handler Wired To Gridview Template Button

Mar 24, 2011

I get an error when attempting to navigate to the page containing this gridview. The error is
'SelectPackage_Click' is not a member of 'ASP.offer_aspx'.

here my page directive:


Here is my markup. Eventhough SelectPackage_Click is present in the code behind, it is not wired up with the button control.


View 5 Replies

Forms Data Controls :: Custom GridView ImageButton Click Event Handler Not Firing?

Feb 10, 2011

I am trying to create a custom GridView with a header toolbar at the top that will contain icons to export the grid view to different formats like excel, word, etc.. The problem is, I cannot get the method to fire that is assigned to handle the click event for the corresponding Image Button. The page posts back, but the code I have in the method to handle the click event does not fire. I have followed examples in other posts and from what I can tell I have followed what others have done. Can somebody take a look at see if they can find something that I am doing wrong.


View 1 Replies

Forms Data Controls :: DropDownList Inside GridView Inside UpdatePanel SelectedIndexChanged Event Not Firing?

Aug 16, 2010

I have an UpdatePanel with a GridView. This GridView has a template column that is a DropDownList. The problem is that the SelectedIndexChanged event does not fire for the DropDownList. Here is the code:


The codebehind:


View 2 Replies

Data Controls :: Assign JQuery Click Event Handler To GridView Row

May 7, 2015

How we call a function on selecting a row in ASP.Net ....

View 1 Replies

Get Total Row Count And Why Is The GridView's DataSource Property Null In The DataBound Event Handler

Jul 22, 2010

I wanted to get the total row count in a GridView's databound event handler, so I tried the following:

protected void grid_DataBound(object sender, EventArgs e)
GridView grid = (GridView)sender;
DataSet data = grid.DataSource as DataSet;
if (data == null)
int totalRows = data.Tables[0].Rows.Count;

The problem is that the grid.DataSource property is null. The DataSourceID property is not null, so does that mean that I can't access the DataSource object in the DataBound event handler unless I assign the DataSource property directly?

Edit1: Here is the code in my GridHelper class for adding rowcount to the BottomPagerRow. I would like to get rid of the requirement to pass in the ObjectDataSource, but can't because I need to use the Selected event to get total row count. Hence the reason for the question. I also think this might be better in a custom control where I can access ViewState, and/or create child controls during the Init event (I still have a problem to resolve with the way the pager renders with an extra cell), but then I'd still have the problem of how to get to the total row count when the DataSource itself doesn't appear to be available in any GridView events.

Edit 2: Not really relevant to the specific problem, but I resolved the problem I was having with the pager rendering so i've updated the code posted. I found the trick here: [URL]

#region Fields
private int totalRows = -1;
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="GridHelper"/> class.
/// Adds EventHandlers to the GridView to display results from the ObjectDataSource in the footer.
/// Marked as obsolete because AddResultsToFooter method provides a static access to the same functionality
/// An instance of GridHelper is required by the passed in GridView to store the totalRows value between the two event handlers
/// </summary>
/// <param name="grid">The grid.</param>
/// <param name="source">The ObjectDataSource linked to the GridView.</param>
[Obsolete("Use AddResultsToFooter instead.")]
public GridHelper(GridView grid, ObjectDataSource source)
source.Selected += source_Selected;
grid.PreRender += grid_PreRender;
#region Event Handlers
private void grid_PreRender(object sender, EventArgs e)
GridView grid = (GridView)sender;
if (grid.HeaderRow != null)
grid.HeaderRow.TableSection = TableRowSection.TableHeader;
//Add a cell to the bottom pager row to display the total results
if (grid.BottomPagerRow == null || !grid.BottomPagerRow.Visible)
//Get the control used to render the pager
Table tblPager = grid.BottomPagerRow.Cells[0].Controls[0] as Table;
if (tblPager == null)
if (totalRows < 0)
//The DataSource has not been refreshed so get totalRows from round trip to client
addResultsToPagerTable(tblPager, grid.Attributes["results"]);
int firstRow = grid.PageIndex * grid.PageSize + 1;
int lastRow = firstRow + grid.Rows.Count - 1;
string results;
if (totalRows <= grid.PageSize)
results = string.Format("<span class='grid-pager'>{0} Results</span>", totalRows);
results = string.Format("Results <b>{0}</b> to <b>{1}</b> of <b>{2}</b>", firstRow, lastRow, totalRows);
addResultsToPagerTable(tblPager, results);
//Need to store the information somewhere that is persisted via ViewState, and we don't have access to ViewState here
grid.Attributes.Add("results", results);
/// <summary>
/// Handles the Selected event of the source control. Gets the total rows, since it is not possible to access them from the GridView.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.Web.UI.WebControls.ObjectDataSourceStatusEventArgs"/> instance containing the event data.</param>
private void source_Selected(object sender, ObjectDataSourceStatusEventArgs e)
if (e.ReturnValue is DataView)
totalRows = ((DataView)e.ReturnValue).Count;
else if (e.ReturnValue is EntitySet)
totalRows = ((EntitySet)e.ReturnValue).Count;
#region Private Methods
private static void addResultsToPagerTable(Table tblPager, string results)
//Get a handle to the original pager row
TableRow pagesTableRow = tblPager.Rows[0];
//Add enough cells to make the pager row bigger than the label we're adding
while (pagesTableRow.Cells.Count < 10)
pagesTableRow.Cells.Add(new TableCell { BorderStyle = BorderStyle.None });
//Add a new cell in a new row to the table
TableRow newTableRow = new TableRow();
newTableRow.Cells.AddAt(0, new TableCell
Text = results,
BorderStyle = BorderStyle.None,
ColumnSpan = pagesTableRow.Cells.Count
tblPager.Rows.AddAt(0, newTableRow);
#region Public Methods
/// <summary>
/// Adds EventHandlers to the GridView to display results from the ObjectDataSource in the footer.
/// </summary>
/// <param name="grid">The GridView.</param>
/// <param name="source">The ObjectDataSource linked to the GridView.</param>
public static void AddResultsToFooter(GridView grid, ObjectDataSource source)
if (grid == null)
throw new ArgumentNullException("grid", "grid is null.");
if (source == null)
throw new ArgumentNullException("source", "source is null.");
new GridHelper(grid, source);

View 1 Replies

Forms Data Controls :: How To Get SelectedIndexChanged Event From UC

Feb 17, 2010

I have a dropdown list sitting on a user control and I need to evoke the SelectedIndexChanged from the dropdownlist. How do I make this SelectedIndexChanged event available on my UC?

View 2 Replies

Forms Data Controls :: How To Call A Button Click Event On From An Event Handler

Sep 29, 2010

I got an event handler like this, in this event, i wanted to call another button click event. How can I do that?


if (ds.Tables[0].Rows.Count == 0)

View 3 Replies

Forms Data Controls :: Dropdown's Selectedindexchanged Event Not Fire In IE?

Feb 11, 2010

In one webpage,

There is one updatepanel in that one gridview,

there is one dropdown in headerrow of gridview,

dropdown's selectedindexchanged event fire in FireFox but not in IE.

View 7 Replies

Forms Data Controls :: Get Datavaluefield On SelectedIndexchanged Event Of Another Ddl Using Linq?

Aug 31, 2010

I have 2 dropdownlist - State and City. I want to fill city drop down list on selectedIndexChanged event of state drop down list. I fill the State ddl ( DataTextField = "Locationname" & DataValueField = "Locationid" ) using linq and when i changed state I didn't get "Locationid" and I got error - " conversion from string "Locationid" to type "Double" is not valid" .

following are the code


View 2 Replies

Forms Data Controls :: Call Javascript From SelectedIndexChanged Event In C#?

Feb 15, 2010

I want to call javascript from SelectedIndexChanged event of to do that

protected void gridSlave_SelectedIndexChanged(object sender,
EventArgs e)


View 9 Replies

Web Forms :: Dropdownlist Control SelectedIndexChanged Event?

Jun 22, 2010

I have one dropdownlist control which populates values to other controls. Means upon selecting item in dropdownlist, related data is populated in other controls. I have also assigned dropdownlist's autopostback to TRUE. Everything is working good as far as dropdown has more than one item.

Whenever there is only one item, selectedindexchanged event is not fired (obviously.....) and eventually the data is not populated to other controls.

How could I get rid of this scenario? I mean which event should I use to avoid this?

At this time, I have just added the first item as something like "---Select Item---" , so when end-user has to select different item and thus the selecteditemindexchanged is fired. no biggie... but just wondering if proper solution is available....

View 3 Replies

Copyrights 2005-15, All rights reserved