Click here to Skip to main content
12,241,265 members (49,206 online)
Rate this:
Please Sign up or sign in to vote.
See more: VB ASP.NET Gridview VB.NET , +
First of all. Im very new to ASP.NET so bear with me.

Scenario: User is presented with a web page asking for a customer number and then hits a go button. The Go button calls another page and passes on the customer number to that page. The page loads a gridview . THe girdview's datasourece loads an sqlsource. The source calls a stored procedure and passes the data back to the gridview filtered by the previoulsy obtained customer number. Here is where it gets tricky. The Gridview shows some data the procedure pulled from an existing table in the sql server. There are also some empty fields that after hitting the edit buttton, the user has to populate. Once the user populates the fields Update/insert is selected and the the insert procedure takes the record wiht added field data and inserts it into a speerate table in the sql database. WHat i need now is the gridview to show the updated record i just inserted into the new table by calling a didfferent datasource passing on the serial number the user has entered in the of the empty fields.

PS. i use VB.

below is the aspx and aspx.vb file as i have them now. THe sqldatasource3 is the source that the serial number needs to be passed on to to obtain the updatyed records in the separate sql table.

I am greatfull or any help you can give me.


<%@ Page Language="VB" AutoEventWireup="false" CodeFile="REWTSCusNum.aspx.vb" Inherits="REWTSEquip" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
        DataSourceID="REWTSEquip1" EnableModelValidation="True" AllowPaging="True"
        AutoGenerateEditButton="True" PageSize="4" Height="150px">
            <asp:TemplateField HeaderText="MANUFACTURER" SortExpression="MANUFACTURER">
                    <asp:TextBox ID="TextBox1" runat="server" maxlength='25'   Text='<%# Bind("MANUFACTURER") %>'></asp:TextBox>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("MANUFACTURER") %>'>


Partial Class REWTSEquip
    Inherits System.Web.UI.Page
    Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
    End Sub
    'logout subroutine
    Sub btnLogout_OnClick(ByVal Src As Object, ByVal E As EventArgs) Handles btnLogout0.Click
    End Sub
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    End Sub
    Protected Sub SqlDataSource1_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles SqlDataSource1.Selecting
    End Sub
End Class
Posted 27-Jun-11 5:00am
losmac 27-Jun-11 12:14pm
If you can load data and view it in DataGridView, where is the problem?
Do you need help with sql command: "SELECT * FROM [REWTSEquipment] WHERE ([SERIAL] = @SERIAL" ?
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Do you want to apply 2 datasources to single Grid? if it is so then it is not possible. If you are using Grid within Grid then it is possible.

Also your question is not clear, what you want to do exactly. I believe you should do some googling for your problem. If you are new to ASP.Net, go with some ASP.Net beginner book.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

I am opening a page containing a gridview that is populated using an sqldatasource and a parameter obtain from the the preceding page. When the grid is populated, the user has the option to edit any of the records in the gridview. When the user edits a record and hits update, what really happens is that the updated record is actually written to a different table in sql. Not the original source table. What i want to happen is that if a user hits the UPDATE control in the gridview the gridview needs to return the record as it was edited from the new table. I can't explain it any simpler than this. So in essence what i need to have happen is that when a user edits a record the gridview needs to remember that record (SERIAL which is a column in the girdview) and after the user hits update the code needs to grab the serial value and pass that to a second sqldatasource and retrirve that record from the new table and populate the gridview with it. i dont care if we have to hide the original gridview and call up a second gridview on the same page . hope this makes more sense.

Thank you.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

just repopulate the grid with the same id which you have when the page load Smile | :)
AnthonyGC 13-Jul-11 10:21am
Ok, any more suggestions? Could I try and work with a page reload fucntion to accomplish this?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 28 Jun 2011
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100