473,395 Members | 1,471 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

how to bind record to form view from different tables at different time

hi all
i am using formview control(asp.net 2.0) 1rst time. don't know much about it.
i want to display record in it from different tables at different time. like 1rst time form view is showing record of tableEmp. 2nd time same formview showing record of tableSalary.i am using c# coding. is it possible to bind data from code behind file? if possible, how?

i would also like to know how i can bind formview from datagrid(select event)
thanks.

regards
sudha
Oct 25 '07 #1
3 2359
kunal pawar
297 100+
hi all
i am using formview control(asp.net 2.0) 1rst time. don't know much about it.
i want to display record in it from different tables at different time. like 1rst time form view is showing record of tableEmp. 2nd time same formview showing record of tableSalary.i am using c# coding. is it possible to bind data from code behind file? if possible, how?

i would also like to know how i can bind formview from datagrid(select event)
thanks.

regards
sudha
It is posible by Changing Datasource on gridview
Oct 25 '07 #2
It is posible by Changing Datasource on gridview
thnks 4r ur reply sir. but u didn't get my question. if u no please reply. 1rst thing how to bind data to form view from "d.aspx.cs" page
i've done dis but not working n also not showing error
---- -----------
// here is coding for query.
SqlDataAdapter sdaSearch = new SqlDataAdapter();
sdaSearch.Fill(ds);

FormView2.DataSource = ds;
FormView2.DataBind();

thnks.
regards
sudha
Oct 25 '07 #3
kunal pawar
297 100+
try this one

// FormView control ////////////////////////////////
<asp:FormView ID="FormView1" runat="server" CellPadding="4" ForeColor="#333333"
DataKeyNames="AutoID" DataSourceID="SqlDataSource1" AllowPaging="true">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#EFF3FB" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<ItemTemplate>
<table border="1">
<tr>
<td>AutoID</td>
<td><%# Eval("AutoID") %></td>
</tr>
<tr>
<td>Name</td>
<td><%# Eval("Name") %></td>
</tr>
<tr>
<td>Address</td>
<td><%# Eval("Address") %></td>
</tr>
<tr>
<td>Phone</td>
<td><%# Eval("Phone") %></td>
</tr>
<tr>
<td>City</td>
<td><%# Eval("City") %></td>
</tr>
<tr>
<td> </td>
<td>
<asp:Button ID="btnEdit" runat="Server" CommandName="Edit" Text="Edit" />
<asp:Button ID="btnInsert" runat="Server" CommandName="New" Text="New" />
<asp:Button ID="btnDelete" runat="Server" CommandName="Delete" Text="Delete" OnClientClick="return confirm('Are you sure to Delete?');" />
</td>
</tr>
</table>
</ItemTemplate>
<EditItemTemplate>
<table border="1">
<tr>
<td>AutoID</td>
<td><%# Eval("AutoID") %></td>
</tr>
<tr>
<td>Name</td>
<td><asp:TextBox ID="TextBox1" runat="Server" Text='<%# Bind("Name")%>'></asp:TextBox></td>
</tr>
<tr>
<td>Address</td>
<td><asp:TextBox ID="TextBox2" runat="Server" Text='<%# Bind("Address")%>'></asp:TextBox></td>
</tr>
<tr>
<td>Phone</td>
<td><asp:TextBox ID="TextBox3" runat="Server" Text='<%# Bind("Phone")%>'></asp:TextBox></td>
</tr>
<tr>
<td>City</td>
<td><asp:TextBox ID="TextBox4" runat="Server" Text='<%# Bind("City")%>'></asp:TextBox></td>
</tr>
<tr>
<td> </td>
<td>
<asp:Button ID="btnUpdate" runat="Server" CommandName="Update" Text="Update" />
<asp:Button ID="Button1" runat="Server" CommandName="Cancel" Text="Cancel" />
</td>
</tr>
</table>
</EditItemTemplate>
<InsertItemTemplate>
<table border="1">
<tr>
<td>AutoID</td>
<td><%# Eval("AutoID") %></td>
</tr>
<tr>
<td>Name</td>
<td><asp:TextBox ID="TextBox1" runat="Server" Text='<%# Bind("Name")%>'></asp:TextBox></td>
</tr>
<tr>
<td>Address</td>
<td><asp:TextBox ID="TextBox2" runat="Server" Text='<%# Bind("Address")%>'></asp:TextBox></td>
</tr>
<tr>
<td>Phone</td>
<td><asp:TextBox ID="TextBox3" runat="Server" Text='<%# Bind("Phone")%>'></asp:TextBox></td>
</tr>
<tr>
<td>City</td>
<td><asp:TextBox ID="TextBox4" runat="Server" Text='<%# Bind("City")%>'></asp:TextBox></td>
</tr>
<tr>
<td> </td>
<td>
<asp:Button ID="btnSave" runat="Server" CommandName="insert" Text="Insert" />
<asp:Button ID="Button1" runat="Server" CommandName="Cancel" Text="Cancel" />
</td>
</tr>
</table>
</InsertItemTemplate>
</asp:FormView>


// SqlDataSource Control ////////////////////////////////
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString='<%$ ConnectionStrings:ConnStr %>'
SelectCommand="Select * FROM SampleForTutorials ORDER BY [Name]"
DeleteCommand="Delete FROM SampleForTutorials WHERE AutoID = @AutoID"
UpdateCommand="UPDATE SampleForTutorials SET Name = @Name, Address = @Address, Phone = @Phone, City = @City WHERE AutoID = @AutoID"
InsertCommand="INSERT INTO SampleForTutorials (Name, Address, Phone, City) VALUES (@Name, @Address, @Phone, @City)">
<DeleteParameters>
<asp:Parameter Name="AutoID" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="AutoID" Type="Int32" />
<asp:Parameter Name="Name" Type="string" Size="50" />
<asp:Parameter Name="Address" Type="string" Size="200" />
<asp:Parameter Name="Phone" Type="string" Size="50" />
<asp:Parameter Name="City" Type="string" Size="20" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Name" Type="string" Size="50" />
<asp:Parameter Name="Address" Type="string" Size="200" />
<asp:Parameter Name="Phone" Type="string" Size="50" />
<asp:Parameter Name="City" Type="string" Size="20" />
<asp:Parameter Name="AutoID" Type="Int32" />
</InsertParameters>
</asp:SqlDataSource>
Nov 5 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Steve Strik | last post by:
My Problem: I have created a database here at work that is exhibiting some very strange behaviour. Essentially the database is structured in a manner where one table is a master record table...
7
by: Megan | last post by:
Hi everybody- I inherited a database that somehow uses a bound combo box as a record selector. Let me give you some background. The form is based on data from 2 tables. The first table, Person,...
8
by: Bri | last post by:
Greetings, I'm having a very strange problem in an AC97 MDB with ODBC Linked tables to SQL Server 7. The table has an Identity field and a Timestamp field. The problem is that when a new record...
19
by: davidgordon | last post by:
Hi, I need some pointers/help on how to do the following if it possible: In my access db, I have the following: Tables: Products, Sub-Assembly, Product-Pack Table, Products
3
by: Nicolas Boretos | last post by:
Hello, Beginning access user here. I am displaying the table and its existing form at the same time. I would like to double-click on a row in the table and have the form go to/display the...
2
by: sudhashekhar30 | last post by:
hi all i am using form view. i want to display record in form view from different table. like 1rst time its showing record from tableemp. 2nd time i want to show record of tableSalary in same form...
0
by: dan | last post by:
Hi, I have a form that displays record fields. The record has a 'type' field. I'd like to use different controls for one of the fields based on the type. I initially thought of putting all...
25
by: tekctrl | last post by:
Anyone: I have a simple MSAccess DB which was created from an old ASCII flatfile. It works fine except for something that just started happening. I'll enter info in a record, save the record,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.