|
where id = @id should work
you need to make sure it is jus selecting the one id
can you post your whole code
|
|
|
|
|
<asp:sqldatasource id="SqlDataSource1" runat="server" connectionstring="">]]>"
SelectCommand="SELECT * FROM [tblname]" InsertCommand="INSERT INTO tblname(name) VALUES (@name)"
UpdateCommand="UPDATE [tblname] SET name=@name WHERE id = @id">
<insertparameters>
<asp:parameter name="name">
<asp:parameter name="name">
|
|
|
|
|
where is @id declared, what is it? textbox value, hardcoded value?
|
|
|
|
|
id is just a field in the table, it's of type identity and is incremented for one with adding one more record in the table, something like autonumber in MS Access. With @id I think it should update the field with the current id is open. As I told you, I am a beginner so maybe I did some mistake, and any help will be appreciated. Thanks ahead
|
|
|
|
|
let me give you an example of an update statement
SqlCommand sqlcommand = new SqlCommand("as_insert_command",
sqlConn);
sqlcommand.CommandType = CommandType.StoredProcedure;
SqlParameter para1= sqlcommand.Parameters.Add("@id",
SqlDbType.Int, 4);
para1.Value = textboxid;
see the @id is set against a textbox id
so if someone enters a value in the textbox, that value will update the id
is this what you are trying to achieve
the id needs to be set somewhere this is why i am confused
|
|
|
|
|
I see...but the thing is that I am not using any textboxes, I am just attaching a connection to the database with the DetailsView, and cause in my test database, there is only two fields: ID and Name, that's why I put WHERE id=@id. So if I want to make a statement for StoredProcedure for updating the fields, how should I declared?? Let's say, I have just two fields, like in my test DB. Thanks very much!!
|
|
|
|
|
I really don't understand what you are trying to achieve sorry
|
|
|
|
|
OK . Thx for your help anyway, and sorry for taking your time. Have a nice day!
|
|
|
|
|
hi, i'm begginer also just like u. i don't know if my answer can help u, but here goes.
where id=@id
when u use this, all the id in the table will be update. u have to put a text box where u can put which id u want to update.
Dim sql = "UPDATE table1 SET name = @name WHERE id = @id"
conn = New SqlConnection(ConfigurationSettings.AppSettings("strConn"))
comm = New SqlCommand(sql, conn)
comm.Parameters.Add(New SqlParameter("@id", SqlDbType.Char, 50))
comm.Parameters("@id").Value = textbox1.Text.Trim
update the table that u want where the id that u choose r from textbox1. when u set the value for id is from the textbox, then it will only update name where the id is from the textbox that u enter.
i'm doing the same project just like yours.
hope it will help u.
|
|
|
|
|
Hi
I ahve a required field validator which runs when a user clciks a button and a textbox is blank. However I have another button on the page which is a cancel button and iw ant to the user to be able to press this even if the required validator runs
however it seems to disable every control in the page until a value is entered in the textbox
any help would be great?
thsanks
|
|
|
|
|
Set the validator property named "EnableClientScript" to false
Mohamed Gouda
Egypt
|
|
|
|
|
yeah but when i turn that to false the entire validator doesnt work
i still want it to work but when it runs I want to be able to click on the cancel button on the page
at the moment if the validator runs it disbales all buttons on the page
thanks
|
|
|
|
|
No idea why it is setting all other controls to disabled state.How ever if you dont want the validation conrol go get in to action when the cancel button is clicked then set the CausesValidation property of the cancel button to false.
Thanks
Laddie
Kindly rate if the answer was helpful
|
|
|
|
|
use cause validation in the button that sorted it for me
|
|
|
|
|
|
would selecteditem not be the better option
|
|
|
|
|
a-+s-+p-+ wrote: would selecteditem not be the better option
no handler for selectedItem changes
Mohamed Gouda
Egypt
|
|
|
|
|
Its very simple... just add a button column with command name="select"
and then write ur code in the selected index changed event...
When you fail to plan, you are planning to fail.
|
|
|
|
|
Thanks .. it works
But there is noway to select the row from any field like the Desktop Datagrid ?? this is very strange !!!
Mohamed Gouda
Egypt
|
|
|
|
|
Hi,
I have to generate Report in MS excel from my ASP.Net/C# Application.
How i should proceed. Any suggestion,Tutorial,link would be great help.
Thanks
|
|
|
|
|
|
Hi
in page load i am binding data to gridview control . i have button in that same page while clicking this button i want that
grid view data to be downloaded to the client side in .txt format . now i did how to convert that gridview data to txt format .
but it saving in server machine(i gave server.mappath for path) . it should downloadad to client machine . how to do that ?
|
|
|
|
|
Some thing Quick...
In the button click write like this.
Response.Write("");
Response.Write("window.open('"+ Server.Mappath(path) + "');");
Response.Write("");
Thanks
Laddie
Kindly rate if the answer was helpful
|
|
|
|
|
Response.Redirect(Server.Mappath(path))
Mohamed Gouda
Egypt
|
|
|
|
|
I have a lot of experience using C#. I want to design a website with roles and users. Im looking for a free pdf book that can get me started, including setting up visual studio (the server) and also how I can use my dasktop pc to run as a server aswell for running the site during development.
If u knw of a good book that covers my problems....
Is this chair taken
|
|
|
|