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

Post New Web Links

Binding GridView with SqlDataSource at runtime?

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net

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.

View Complete Post

More Related Resource Links

Binding the multiple drop down boxes in GridView using JQuery in ASP.NET

Here is the code for binding the multiple drop down boxes in GridView using JQuery in ASP.NET

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.

Need some help BINDING to Gridview


Here is how I set this up....Still not working.

  •     Dim cs As ConnectionStringSettings   
  •     cs = ConfigurationManager.ConnectionStrings("ConnectionStringVendors")   
  •     Dim connString As String = cs.ConnectionString   
  •     Dim dbConnection As New SqlConnection(connString)   
  •     Dim query As String  
  •     Dim query1 As String  
  •     query = "SELECT keyID, projectNum, projectDescripti
  • Binding xml data (which is return from Url) to gridview


    I have used Yahoo BOSS API for internal search. This API return string and i want to bind it with gridview. How can i achieve this following is the code

    string AppId = "sRP_q9bV34HI_zNyuahPFBGnf1SHyBaIKCtvEjB89EuiNJI6fcfSwAFbwAFSsCV_";
    //string Query = "site:way2k.com engineering colleges in pune";
    string Query = "colleges in pune"; int NumResults = 10;
         int NumResults = 10;
    System.Net.WebClient webClient = new System.Net.WebClient(); request = string.Format( "http://boss.yahooapis.com/ysearch/web/v1/{1}?appid={0}&format=xml&results={2}", AppId, Query, NumResults); byte[] response = webClient.DownloadData(request); string responseXML = System.Text.UTF8Encoding.UTF8.GetString(response); return responseXML;

    this code returns result in xml format, how can i bind this XML to gridview so that it looks like search result

    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?

    binding innerhtml data to gridview

    I have innerhtml data in database(which contains both text and picture) fro example it will look like this <P>&nbsp;which one is afgnfgdggm</P><P>gfglkfgfgriwtiouweoituwetjhewoituewointwektiujwent</P><P><IMG src="http://localhost:3032/IHSOnline/editorimages/UserImages/7b709.jpg" width=150>&nbsp;</P> I have to bind this data to gridview.These are the steps i tried.......I took this data to a string using Server.HtmlDecode .(this step i have done in an imagegrab.aspx page using id of image,to retrieve and bind data dynamically to griview). in gridview i made a templatefield and code is like this <asp:TemplateField HeaderText="Question"> <ItemTemplate> <%# FormatURL(DataBinder.Eval(Container.DataItem, "question_id")) %> </ItemTemplate> </asp:TemplateField> where server side function public string FormatURL(object strArgument) { return ("imagegrab.aspx?id=" + strArgument); } I tried to call imagegrab.aspx.But it is not working.Can anyone describe me how to call and pass this id to imagegrab.aspx....... and also how to bind this data to gridview

    binding datetimecontrol,dropdown,textbox inside gridview and update each gridviewrow

    i have a web part with datetimecontrol(sharepoint) inside a  gridview. when the page loads this this gridview will be loaded with dtc control and the selecteddate would be one of the columns in the splist.also gridview contaisn dropdowns, textboxes, when an update button cliked inside grid, i need to save the info in the splist.  currently i am not getting the value  bound with dtc control. i am getting blank date inside dtc. though in the  rowdatabound event i amcapturing the values due to some reason i am not able to view the value in the DTCcontrol. can anybody give me help me how to achieve this? any  help links/ sample code.. appreciate the help                         

    Binding Web Service Result in asp:gridview and enable sorting(paiging)

    Hello everyoneI have web service and gridviewI'm binding it without problemcode: protected void Page_Load(object sender, EventArgs e) { GetCallsService wservice = new GetCallsService(); List<Call> list = wservice.getCalls(2); GridView1.DataSource = list; //GridView1.AllowSorting = true; GridView1.DataBind(); } But I want to enable sorting and(or) paging.   GridView1.AllowSorting = true; this doen't solves problem.everything worls fine if I'm usign sqlDatasource but when datasource is web service it doesn't wokdoes enyone know solution?

    Textbox -> value -> gridview -> Sqldatasource?

    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

    Problem Binding DropdownList in a gridView to a datasource

    I have a Dropdownlist in an itemTemplate in a gridview. My gridView binds to dataTable1 (from which the selected value for dropdown comes from) and dropDown binds to dataTable2 (i need to get DataValueField and DataTextField from here).<asp:TemplateField HeaderText="Category"> <ItemTemplate> <asp:DropDownList ID="Cat" runat="server" SelectedValue='<%#Bind("CATEGORY") %>' > </asp:DropDownList> </ItemTemplate> <FooterStyle BorderStyle="None" /> <HeaderStyle BorderStyle="None" /> <ItemStyle BorderStyle="None" /> </asp:TemplateField>How do I do that? thanks in advance!

    GridView column/row data binding problem

    Hi All, I have a table with the following structure: Attribute------------- AttributeIdWeekNoDayNoAttribute1Attribute2Attribute3Attribute4Attribute5 ........ likewise. I want to display these data in a gridview in the following manner                                  Sunday    Monday Tuesday ............ (till Saturday) - should be gridview columns, I can retrieve this using dayno Attribute 1 Attribute 2 Attribute 3 Attribute 4 .......... like wise attributes should be taken in to rows.Is this possible in a gridview, if so how can I do that?

    Binding Gridview using MDX query

    Hi, I tried to show results in a gridview using MDX query. In addition, I created a dropdownlist. I was hoping that the content of the gridview would change when I choose different conditions  from the dropdownlist. However, there was an error: "The result set returned by the server is not a rowset."  I did much research on the problem, but I still don't understand. The following is my code: public partial class Default3 : System.Web.UI.Page { StringBuilder sb = new StringBuilder(); protected void Page_Load(object sender, EventArgs e) { string conString = "Datasource=localhost;Initial Catalog=PIsystem"; AdomdConnection con = new AdomdConnection(); con.ConnectionString = conString; con.Open(); AdomdCommand cmd = con.CreateCommand(); cmd.CommandText = sb.ToString(); DataTable dt = new DataTable(); dt.Load(cmd.ExecuteReader()); GridView1.DataSource = dt; GridView1.DataBind(); con.Close(); } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { if (DropDownList1.SelectedIndex > -1) { if (DropDownList1.Items[1].Selected) { sb.Append("SELECT {[Measures].[NBP]} ON COLUMNS, {[Time].[Month]} ON ROWS"); sb.Append("FROM [PISystem]"); sb.Append("WHERE ([Employ].[Region

    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 ?

    Why does "reader" in my c# codebehind skip the first row of data when binding to a gridview?


    Argh.. I'm making the switch from vb.net to c#, and am just trying to bind some data from a reader in my c # codebehind, but no matter what, the gridview always skips the first row returned from my stored procedure.  What am I doing wrong???

    comm.CommandText = "123456";
    comm.Parameters.AddWithValue("@SubSectionParentID", SubSectionParentID.Text);
    reader = comm.ExecuteReader();
                      while (reader.Read())
                gvMenu.DataSource = reader;


    How to get Checkbox value created at runtime above gridview header


    I have creted a checkbox for each column of grid at the top of the header in row created event. I need to check wheather checkbox is checked after button click event.

    //Build custom header.

                    GridView oGridView = (GridView)sender;
                    GridViewRow oGridViewRow = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert);
                    TableCell oTableCell = new TableCell();

                    //Add Staff_ID
                    CheckBox chkStaffID = new CheckBox();
                    chkStaffID.ID = "chkStaff_ID";
                    chkStaffID.Text = "Hide";
                    chkStaffID.CheckedChanged += new System.EventHandler(chkStaffID_CheckedChanged);

    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=?"

    Merging gridview header after binding in winforms



    Note : I am talking about Winform grid only

    I want to bind a grid, structure should look like below after binding with the datatable,


        26_sept            l         27_sept          l            28_sept       l           29_sept

    col1 col2 col3 col4 l   col1 col2 col3 col4  l   col1 col2 col3 col4 l  col1 col2 col3 col4

                               l                               l                              l


    Here, I have datatable dt 16 columns as below but no parent header

    col1 col2 col3 col4 l   col1 col2 col3 col4  l   col1 col2 col3 col4 l  col1 col2

    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