.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Textbox -> value -> gridview -> Sqldatasource?

Posted By:      Posted Date: September 07, 2010    Points: 0   Category :ASP.Net
Hi guys. I have textbox that searches for first or last name. Result show in gridview. But when add value in text box and push my button Find nothing happen. Here code: aspx:   ........ <asp:GridView runat="server" AllowPaging="True"                   AutoGenerateColumns="False" DataKeyNames="MobileNum"                   DataSourceID="SqlDataSource5" style="font-family: Verdana"                          onselectedindexchanged="GridView1_SelectedIndexChanged">         <Columns>                         <asp:BoundField DataField="FNAME" HeaderText="FNAME" SortExpression="FNAME" />             <asp:BoundField DataField="LNAME" HeaderText="LNAME" SortExpression="LNAME" />          &nb

View Complete Post

More Related Resource Links

Binding GridView with SqlDataSource at runtime?


Hi, I want to create a generic page which contains a gridview and sqldatasource. I want to put these two controls on .aspx (C#) page but bind them at runtime. It should have selectcommand, updatecommand, deletecommand and insertcommand. Stored procedures are created for that. Help is needed to make it. Please post some link or code. Regards, ap.

Gridview Update outside of SqlDatasource


Is it possible to use a SQLDataSource to populate a gridview but not use the SQLDataSource for Updating?

I wanted to add the update code in the Gridview_RowUpdating event since it is a complex update I need to do.

I get this message when i click the update button

Updating is not supported by data source 'SqlDataSource1' unless UpdateCommand is specified.

Return value from SqlDataSource in GridView ?

Hi, everyone. I have textbox for searching a Names in My database. I return the information from the Select Statement in  GridView, but i want to know the number of affecter rows. How to do that?

GridView bound to SqlDataSource = 2 tier ?


Hi guys,

I've got two questions about n-tier architecture.

I have an aspx page with 2 controls on it - a GridView bound to a SqlDataSource control.
Am I correct in thinking this is 2-tier ?

If I were to replace the SqlDataSource with an ObjectDataSource, and make the database connections/calls/queries via a class in the App_Code folder, this would be 3-tier, right ?

SQLdatasource + gridview + mysql




I have a sqldatasource and a gridview. I work with a mysql 3.51 database.

My problem is :

When I try tu update a record through the update command of the gridview, it doesn't work.  Here is my code :


asp:SqlDataSource ID="SQL_Panier" runat=server ConnectionString="<%$ ConnectionStrings:Connection to NI %>" ProviderName="<%$ ConnectionStrings:Connection to NI.ProviderName %>" SelectCommand="selectcommand"

UpdateCommand="Update Panier SET qtt=@qtt,commentaires=@commentaires WHERE email=?"

Gridview Sorting with SqlDataSource



I had a previous post (found here for reference: http://forums.asp.net/p/1573740/3954537.aspx#3954537) Where I was wanting to hide/assign gridviews and datasource dynamically to reduce the page load time. I now have a user requesting that one of those Gridviews be sortable. I have already gone through and added the sort Expression to each column that is created in the code behind. 

I also added a Gridview Sorting Handler

Protected Sub billingGridview_Sorting(ByVal sender As Object, ByVal e As GridViewSortEventArgs) Handles billingGridView.Sorting

But, when I rebind the data, how to I fill in the sort direction and sort Field? The datasource gets its information from a Stored Proc that does not have an Order By (parameter) in it. The websites I have been reading say to use a datatable or dataview and send the sort field and direction to the query. If I dont do all this in the code behind and allow sorting, the gridview is able to handle sorting itself. Is there any way to do this from the code behind? Or am I going to have to rework this with a query that contains a parameter for the sort direction and field?



gridview.rowcommand + sqldatasource.delete()


I have gridview+sqldatasource. In gridview i have button DELETE. But i want on click this button for some rows execute DELETE command other rows UPDATE. I did:

protected void GridMain_RowDataBound(object sender, GridViewRowEventArgs e)
  if (e.Row.RowType == DataControlRowType.DataRow)
     if (DataBinder.Eval(e.Row.DataItem, "DelFlag").ToString() == "True")
               btnDelete.CommandName = "Delete";
               btnDelete.CommandName = "DeleteVirtual";

protected void GridMain_RowCommand(object sender, GridViewCommandEventArgs e)
        if (e.CommandName == "Delete")
           sourceMain.DeleteCommand = "DELETE FROM [Main] WHERE 
        else if (e.CommandName == "DeleteVirtual")
            sourceMain.DeleteCommand = "UPDATE [Main] SET DelFlag = 'True' WHERE  
@index - DeleteParametrs in sqldatasource. But DELETE works and DELETEVIRTUAL doesn't. Then i insert sourceMain.Delete() in rowcommand after sourceMain.DeleteCommand ... But it's doesn't help m

GridView - table v/s SqlDataSource ?


Hi all,

I have a gridview which i need to populate from a products database, where a user can click on a certain

product (row) and gets directed to a new page with that product ID (where he will see the product details

and so on..)

while this seems easy if i bind the gridview to a SQL Datasource, i face few problems:

1- I need to trim the product descrption and only display the first 30 characters ; some products descrption

is much more than 30 characters and i dont want to display all of it in the gridview ..

2- there is a date/time field in my sql query, which appears in the gridview as "10/21/2010 12:00:00 AM". I

don't want to display the time stamp, but only the date. any idea how?

3- if there are no data to display , the gridview header (product name, product description, entry date,

etc..) will disappear and thus the user will be confused..

As a workaround, I'm thinking of capturing the date in a Datatable, after having manipulated it as required

above, and them running a databind on the gridview, which is feasible but has its own challenges:

1- how do u display a URL with the product ID as a variable?

I'm guessing the first method is better, but I couldn't figure it out...

GridView, BoundField, SqlDataSource and DeleteParameters


Hello All,

I I have a GridView attached to a SqlDataSource and all is working well.  I also have and edit and delete icon attached to each record in the GridView, and again, all is working well.

My problem is when I add a BoundField named 'statusCode', the delete stored procedure fails with:

"Procedure or function 'up_delReference' expects parameter '@statusCode', which was not supplied."

When I remove the BoundField named 'statusCode' from the GridView list, the delete works fine.  I need to show the status in the GridView as the user can chose to see Avtive, Inavtive or Both records and they need to see the status when in Both.

Here is the Code:

<asp:GridView ID="GridViewList" runat="server" DataSourceID="SqlDataSourceList" DataKeyNames="refID" >
		<asp:TemplateField HeaderText="Action">
				<asp:ImageButton ID="ImageButtonEditDetail" runat="server" SkinID="IconEdit" CommandName="Edit" ToolTip="Edit Record" />
				<asp:ImageButton ID="ImageButtonDelete" runat="server" SkinID="IconDelete"  CommandName="Delete" ToolTip="Delete Record" OnClientClick

SqlCeException (0x80004005) Trying to load a page with GridView and a SqlDataSource connecting to SQ



On my local machine everything works fine.

I have uploaded my website to an ISP and while trying to open a page with GridView and a SqlDataSource connecting to SQL CE 4 sdf file following exception gets generated.

Server Error in '/' Application.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlServerCe.SqlCeException: [ 1884,d:\DZHosts\LocalUser\gasasso\www.gasasso.somee.com\App_Data\gasasso.sdf,SeCreateFile ]

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

Textbox Editable GridView in ASP.NET

This article describes how I made a fully editable gridview in C# using ASP.NET 2. The idea is that the GridView looks and works like an Excel spreadsheet. You see all the cells in the table, and you can edit any of the cells you like, and they are automatically updated (i.e. saved to the database). This is very often how people expect data tables to work in web pages, and I've often seen people clicking in vain on un-editable gridview cells, somehow expecting to edit them, and not understanding that they need to click an Edit button at the end of the row.

Editable Gridview with Textbox, CheckBox, Radio Button and DropDown List

This is an example of an editable gridview containing different ASP.NET controls. When user wants to edit values in gridview, she/he can use these controls to edit existing values in Gridview Edit Mode.

Using the Code

Textbox in ItemTemplate inside Gridview, unable to get the value


Hi. I have a itemtemplate inside a gridview.

<asp:TemplateField HeaderText="Enter OTP">
                            <asp:Label ID="Label2" runat="server"
                                style="font-family: Arial, Helvetica, sans-serif; font-size: x-small"
                                Text="PIN Num:"></asp:Label>
                            &nbsp;<asp:TextBox ID="txtPIN" runat="server" Height="21px" Width="100px"></asp:TextBox>

jquery datepicker not popping up in Gridview Edit Template textbox


I have a gridview that I can't for the life of me get the datepicker calender to pop up for.  I've been using the datepicker for months very successfully for a variety of textboxes on the page and inside of formviews but this is the first time I've tried using with gridview.  I didn't expect any issues however can't seem to find anything to work.  I have searched the forums for 2 days and attempted any suggestions found within the solutions to no avail.  I've tried using the CSS to link the datepicker but everything stopped working when I changed the code and my page which uses a css style already got all distorted looking.  Please help!

Here is my gridview (only included a part b/c it is large and am only having problem with the datepicker for the date completed text box)

<asp:GridView ID="GridViewCompleted" runat="server" AllowPaging="True" AllowSorting="True"
        AutoGenerateColumns="False" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid"
        BorderWidth="3px" CellPadding="4" DataKeyNames="job_id" DataSourceID="SourceJobProjectCompleted"
        ForeColor="Black" CellSpacing="2">

search multiple words into textbox and populate all records in gridview related those keywords


I have a textbox and a gridview which is bound to a table

what I want to achieve is a solution where lets say there are two records - e.g. "1. Book and 2. Red", i want a user to type in those words and the gridview shows the results as followed;

1. Book

2. Red

I have set up the sql data source and everything and my like operator is this...

LIKE '%' + @record + '%'

how can I solve this problem?

Changing a textbox's readonly property right before update on a gridview


I have a gridview with a date field. I don't want the user to be able to type in their own date and mess up the format so I made the property readonly. That date is then set by a point and click interface. This is all working fine but when the user clicks update this field doesn't update because it's readonly. If i turn readonly off it works so is there a way to turn off the readonly property right before submit?

How can i add a textbox into a GridView Cell dynamically and how can i retrieve entred data

Hey, i think that the the subject can explain what i need, it's about adding a TextBox control with the code behind into a GridView, and also about how can i retrieve entered data after submitting, im using C#,Thanks.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend