Web Forms :: GridView With Button On Footer - Error On Button Click To Create New Row
Jan 10, 2014
I am using a web form in vs2010 and in my form am having a gridview with button on footer. I have written the code to create a new row while click the button. If I click the button i got the following error
"unable to cast object of type 'system.web.ui.webcontrols.textbox' to type 'mysite.textbox"....
Below is the button click code.
private void AddNewRow() {
int rowIndex = 0;
if (ViewState["CurrentTable"] != null) {
dtCurrentTable = (DataTable)ViewState["CurrentTable"];
DataRow drCurrentRow = null;
if (dtCurrentTable.Rows.Count > 0)
I have a gridview within update panel, in gridview i have footer button to add new row in grid. When i click on footer button to add new row it generate javascript error like "Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500 "
I have a dropdownlist("ddlTemplate") control and a gridview("gvPlanning") control with 1 BoundField column, 1 TemplateField column and remaining columns will be generated dynamically from database.In TemplateFiled Column i have 3 image buttons viz: Edit, update and cancel.Gridview will be populated based on the selecteditem of dropdownlist.
if i click on edit imagebutton, i need to add textboxes dynamically in all the columns of that row except first 2 column. And if i click on Update imagebutton i need to retrieve the textbox values.we can add template field column for textboxes also, but why i am sticking to this method is.. the number of columns changes depending on the selecteditem from the dropdownlist. Eg: If i select india from dropdownlist the number of columns in the gridview would be 4 and if i select UK from dropdownlist the number of columns would be 9 likewise.
I have used the above grid view in my application ... Its working good, no problem.
Upon clicking the Addnewrowbutton, it uses to create a new row dynamically.
What i need is, new row should also be created dynamically, upon pressing enter key in the last textbox on a particular gird view row. User always can't go and click addnewrowbutton every time to create new row. Instead of it, user can press enter in the last textbox on a particular grid view row to create new row.
I have a button in gridview footer template ....Wat i need is on gridview item template last textbox of the row , i will press enter key then the enter key should be focus to the button and button click event should be fired ......
I have created one a page and i am using data grid and data is coming from SQL.Now i want to create one button "Send this on Mail" when user will click this button outlook should open and in the body part my data grid should come with same formatting which i am using in a web page.
How do I do this? Basically, next to the page numbers in the GridView I want a link button to disable paging. This works, but I want the button inside the footer of the GridView, next to the page numbers.
I have created a gridview dynamically from scratch and added it to my aspx page. This works fine, but i have a button in the footer of on of the columns, which when clicked on makes the gridview disappear and doesn't fire the onclick event that it should. This should obviously not be the case. My question is why does the event not fire and why does the gridview vanish? Bear in mind i have never created aa gridview in the code behind before, so excuse me if i am being dense
Code creating columns Dim gvTownships As New GridView 'COLUMNS Dim tmpCategory As New TemplateField tmpCategory.ItemTemplate = New cGridViewTemplate(DataControlRowType.DataRow, "Category") tmpCategory.HeaderTemplate = New cGridViewTemplate(DataControlRowType.Header, "Category") tmpCategory.FooterTemplate = New cGridViewTemplate(DataControlRowType.Footer, "Calculation") 'INFORMATION gvTownships.AutoGenerateColumns = False gvTownships.ID = cmbChoice.SelectedItem.Text gvTownships.ShowFooter = True gvTownships.CssClass = "mGrid" gvTownships.RowStyle.Wrap = False gvTownships.HeaderStyle.CssClass = "mgrid" gvTownships.HeaderStyle.Wrap = True gvTownships.FooterStyle.CssClass = "mGridtf" gvTownships.AlternatingRowStyle.CssClass = "alt" gvTownships.GridLines = GridLines.Both 'add columns gvTownships.Columns.Add(tmpCategory) gvTownships.DataSource = dstSuburbTowhShip gvTownships.DataBind()
Code to add button to footer
Sub InstantiateIn(ByVal container As System.Web.UI.Control) _ Implements ITemplate.InstantiateIn Case DataControlRowType.Footer If columnName = "Calculation" Then Dim btnCalculate As New Button btnCalculate.Text = "Calculate" btnCalculate.CssClass = "button" 'add handler AddHandler btnCalculate.Click, AddressOf btnCalculate_Clicked container.Controls.Add(btnCalculate) End If Case Else ' Insert code to handle unexpected values. End Select End Sub Private Sub btnCalculate_Clicked(ByVal sender As Object, ByVal e As EventArgs) Try Dim btnCalculate As Button = CType(sender, Button) Dim gvRow As GridViewRow = CType(btnCalculate.NamingContainer, GridViewRow) btnCalculate.CommandArgument = "Calculate" Catch ex As Exception End Try End Sub End Class
I have a requirement of creating a form/template/page with controls like radio button, label, some database login for the controls on a button click.
For Example: Need to create a aspx form with 2 radio button, 3 textbox and a button control. For the above controls there shud be some database logic created automatically for storing values in the database.
All should happen in 1 button click.
Can we acheive this using .net. I am using framework 2.0 and VS 2005 and C#.
I want to create a good Pop up on button click. pop up whose "height" , "width" can be controlled. It can be either Jquery pop up or Javascript. In this pop up I want to use asp.net controls and ajax (as normal webpage functionality but in form of pop up) also its background should be little blur when pop up is open.How can i create such pop up?
I want a confirmation password message box on a click button event. if password is correct then it will perform some business rule action. other wise it will show a message you are authorised for it.the button will be server side control at the webpage home.aspx
I have a Master page and a user control on it.and i have a ASP Button on Usercontrol,the has to fire when ever i click on thats the default behaviour ..Now when the home page of my website loads and then i click on the button ,It works perfectly fine but when i navigate to other pages which have same master page the and then click on button the button does no trick!!
is it possible to disable right mouse button click event of a link button. i know to disable it in entire page..but i want to disble it for some controls only.
I have few controls which r validated for blank on a page having 5 buttons
I want the validation to take place only on save button click & not on any other button
<asp:ValidationSummary ID="ValidationSummary1" HeaderText="You must enter a value in the following fields:" EnableClientScript="true" ShowMessageBox="true" ShowSummary="false" DisplayMode="BulletList" runat="server" />
The whole thing is in a form, and it doesnt postback when this button is clicked. Im no good with javascript, but i got a feeling thats not the problem.
i have a web form in which i ve a button which will open a sliding pop up box(jquery) on click of it. In the same page i ve also a linkbutton for downloading files. Now the problem is first time wen i click that button it does nothing. (will not open popup box). Once i click on download button and then if i click that button it will open popup box along with download dialog box. Why is it happening so... is it because am using same event click for both these.
but download option is implemented in gridview_rowcommand()..
In My Web Application i have one master page and Sign out button in menu. When i click log out button logout.aspx will load. i wrote the following code in that page form_load