I've seen a page that had a datagrid that was displaying the database data in textboxes. I didn't see the code, but the guy that made it said that when somebody changed data in the textbox, that it automatically updated in the data base when the textbox field changed.
How can I do this? I want to update an access database without using edit/update buttons. So far, I have a datagrid that shows the data from my db, but it doesn't show it in textboxes, and it's not editable.
That's what my datagrid looks like (I have about 8 more columns though). Here's some of the code w/ it:Code:<asp:DataGrid AllowSorting="true" AlternatingItemStyle-BackColor="#E7EBFA" AutoGenerateColumns="false" Width="800" CellPadding="5" id="cptGrid" runat="server" ShowFooter="false" ShowHeader="true"> <HeaderStyle BackColor="#E6E6FF" /> <Columns> <asp:TemplateColumn SortExpression="Operator" HeaderText="Operator" ItemStyle-Width="100px" > <ItemTemplate> <%# Container.DataItem ( "Operator" ) %> </ItemTemplate> </asp:TemplateColumn> </Columns>
VB Code:
<script language="VB" runat="server"> Sub Page_Load(Sender as Object, E as EventArgs) Dim objConn As OleDbConnection Dim objComm As OleDbDataAdapter Dim strConn As String Dim strComm As String Dim objDataSet As New DataSet 'Build the connection string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" strConn += "Data Source=G:\database\cptInfo.mdb;" strConn += "Persist Security Info=False" 'Build the SQL string strComm = "SELECT cptFileInfo.Operator " 'Im grabbing 8 more cols in the real code strComm += "FROM cptFileInfo" 'Create the connection and command objects objConn = New OleDbConnection(strConn) objComm = New OleDbDataAdapter(strComm, objConn) 'Fill the dataset with the results of the query objComm.Fill(objDataSet, "cptFileInfo") 'Set the grid source to the dataset and bind the data cptGrid.DataSource=objDataSet.Tables("cptFileInfo").DefaultView cptGrid.DataBind() End Sub </script>




Reply With Quote