473,569 Members | 2,770 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Edit Command Problem


I have a form with a search text box and a grid that displays the
results. Within the grid, I have edit command links set up to
response.redire ct to another page that puts the DataKey value in the
query string.

The problem is, when I return to my initial page and do another search
by entering a value in the text box then hitting enter, it takes that
value and sends it to the other page as if I hit the edit link within
the grid. Help appreciated.
<code>
<%@ Page Language="C#" Debug="True" EnableViewState ="True" %>
<%@ import Namespace="Syst em.Data" %>
<%@ import Namespace="Micr osoft.Data.Odbc " %>
<script runat="server">

//The Odbc above is case sensitive and everywhere in code!!! Not
only that,
// but you need to put the Microsoft.data. odbc.Dll in a Bin folder
//in your appliation directory!!!
private void Button1_Click(o bject sender, EventArgs ex){

//Connection Setup

OdbcConnection myConn = new
OdbcConnection( "dsn=SOTAMAS90A UTO");
String strSQL = "SELECT Division + CustomerNumber As
KeyField, Division, CustomerNumber, CustomerName, ContactCode, City,
State, ZipCode, PhoneNumber FROM AR1_CustomerMas ter";

//DataAdapter Setup
OdbcDataAdapter adapter = new OdbcDataAdapter (strSQL,
myConn);

//DataSet, DataAdapter & Table
DataSet objDataSet = new DataSet();
adapter.Fill(ob jDataSet, "dtAR1");

//Set up a filter to use the text box value...
string Filter = "CustomerNa me LIKE '" + TextBox1.Text +
"*'";
objDataSet.Tabl es[0].DefaultView.Ro wFilter = Filter;
objDataSet.Tabl es["dtAR1"].DefaultView.Ro wFilter = Filter;
dgAR1.DataSourc e = objDataSet.Tabl es["dtAR1"];
dgAR1.DataBind( );
}

private void Button2_Click(o bject sender, EventArgs e) {
//Connection Setup

OdbcConnection myConn2 = new
OdbcConnection( "dsn=SOTAMAS90A UTO");
String strSQL = "SELECT Division + CustomerNumber As
KeyField, Division, CustomerNumber, CustomerName, ContactCode, City,
State, ZipCode, PhoneNumber FROM AR1_CustomerMas ter";

//DataAdapter Setup
OdbcDataAdapter adapter = new OdbcDataAdapter (strSQL,
myConn2);

//DataSet, DataAdapter & Table
DataSet objDataSet = new DataSet();
adapter.Fill(ob jDataSet, "dt2AR1");

dgAR1.DataSourc e = objDataSet.Tabl es["dt2AR1"];
dgAR1.DataBind( );
}

private void DataGrid1_EditC ommand(object source,
System.Web.UI.W ebControls.Data GridCommandEven tArgs e) {

Response.Redire ct("CRMhistory. aspx?CustomerNu mber=" + (source
as DataGrid).DataK eys[e.Item.ItemInde x],false);

}

</script>
<html>
<head>

</head>
<body>
<p>
</p>
<p>
</p>
<p>
</p>
<form runat="SERVER">
<p>
</p>
<p>
&nbsp;<asp:Labe l id="Label1" runat="server"
forecolor="Dark Cyan" width="137px">C ustomer
name like:</asp:Label>
<asp:TextBox id="TextBox1" tabIndex="1" runat="server"
EnableViewState ="True" OnTextChanged=" Button1_Click"> </asp:TextBox>
<asp:Button id="Button1" onclick="Button 1_Click"
tabIndex="2" runat="server" Text="Search"></asp:Button>
&nbsp;
<asp:Button id="Button2" onclick="Button 2_Click"
tabIndex="3" runat="server" Text="Show All"></asp:Button>
</p>
<p>
<asp:DataGrid id="dgAR1" runat="server" CellPadding="3"
BorderStyle="No ne" DataKeyField="C ustomerNumber"
OnEditCommand=" DataGrid1_EditC ommand" AutoGenerateCol umns="False">
<HeaderStyle forecolor="Whit e"
backcolor="Dark Cyan"></HeaderStyle>
<AlternatingIte mStyle
backcolor="Beig e"></AlternatingItem Style>
<Columns>
<asp:BoundColum n DataField="KeyF ield"
HeaderText="Key "></asp:BoundColumn >
<asp:BoundColum n DataField="Divi sion"
HeaderText="Div "></asp:BoundColumn >
<asp:BoundColum n DataField="Cust omerNumber"
HeaderText="Cus t No."></asp:BoundColumn >
<asp:BoundColum n DataField="Cust omerName"
HeaderText="Cus tomer"></asp:BoundColumn >
<asp:BoundColum n DataField="Cont actCode"
HeaderText="Con tact"></asp:BoundColumn >
<asp:BoundColum n DataField="City "
HeaderText="Cit y"></asp:BoundColumn >
<asp:BoundColum n DataField="Stat e"
HeaderText="Sta te"></asp:BoundColumn >
<asp:BoundColum n DataField="ZipC ode"
HeaderText="Zip "></asp:BoundColumn >
<asp:BoundColum n DataField="Phon eNumber"
HeaderText="Pho ne"></asp:BoundColumn >
<asp:EditComman dColumn ButtonType="Lin kButton"
UpdateText="" CancelText="" EditText="HISTO RY"></asp:EditCommand Column>
</Columns>
</asp:DataGrid>
</p>
</form>
</body>
</html>
</code>
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #1
0 1572

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
2322
by: Gilles T. | last post by:
How I can get element ID in the edit mode of datagrid control? If I not in the edit mode, there are no problem. <asp:TemplateColumn ItemStyle-CssClass="grid_column_width_3" ItemStyle-HorizontalAlign="center" ItemStyle-VerticalAlign="top"> <ItemTemplate><%# CType(Container.DataItem("DateStatut"),DateTime).ToString("yyyy-MM-dd")...
0
1217
by: San Diego Guy | last post by:
Hi all! I have Datagrid. Within that datagrid I have a drop down list that I set up some values in (a "collection") I set up an edit command column on the datagrid and wrote simple code to get me in to edit mode: sub dgEdit(ByVal s As Object, ByVal e As DataGridCommandEventArgs) dgStatus.EditItemIndex = e.Item.ItemIndex bindData() 'This...
3
4364
by: Tim::.. | last post by:
Can someone please tell me how I go about preselecting an item in a drop drown list when I click the Edit Command in a datagrid? I have tried the following but it doesn't work for me! I would be really grateful for any assistance! Thanks
3
19257
by: misiek | last post by:
Hi all. I have following problem: 1. In my web page I have a GridView control, which does not have a DataSourceId set in designer. 2. When user presses Start button then I create programatically a dataSet, set it as a DataSource for my GridView an add it to Session. 3. I want my users to be able to edit data displayed in GridView, so I...
0
984
by: Kaushik Gadani | last post by:
I am using VB as code behind of ASP.Net (Framework 1.1) I want to call grid's edit command through javascript. This requirements comes, when I want to facilitate user to call edit command by clicking any of the columns of particular row. Please note I can do this with help of assigning edit command to all columns but that will give hyperlink...
0
6029
by: den 2005 | last post by:
Hi everybody, I am not familiar using Gridview, I created a Gridview with Edit Command Button, but when I click the update Command button this error message below is displayed, what and where is the problem? I am confused. Can anyone show me exactly to do edit process of Gridview using Edit Command button properly? Thanks. Error Message:...
9
2711
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the code: <script runat="server"> Dim sqlConn As New SqlConnection(".....") Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs) If Not...
0
1508
by: jmacduff | last post by:
Big question: How to enable edit/update commands to work when setting the sqldatasource select command from code behind. Details: I have a GridView using a sqldatasouce with the select and update commands set. The gridview is part of a "admin" page where the admin will view the data, then use the gridview edit/update buttons to update...
1
2157
by: ollielaroo | last post by:
Hi guys, Firstly I did do a search for this one first but I couldn't find anything related in this forum. I am using Dreamweaver MX and trying to build admin pages for an ASP site. My problem is I have Categories and various Products in each Category. I'm trying to build a page to EDIT/UPDATE each product.I want to be able to change the...
0
7609
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7921
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7964
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6278
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5504
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1208
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.