|
hi all
i have a gridview in a webpage, i set the datasource property of gridview to a datable so it will display the record available is the table now i have a delete button for each row in gridview but i cant able to do the code for delete button, the problem is how could i find the id for the record to which i click on delete button.
plz some body help me for the same
regards
Yogesh Agarwal
|
|
|
|
|
yogesh_kumar_agarwal wrote: but i cant able to do the code for delete button, the problem is how could i find the id for the record to which i click on delete button.
For this you need to keep one primary column on your datatable. When binding to gridview make this column to invisible. Eventhough it is invisible, you can access it by specifying the cell. So when delete button got click, you need to find out this hidden value. This will be the key for the record to be deleted.
|
|
|
|
|
Thanks for the reply but
I know these whole things, the problem is i am unable to got that id feild at runtime when i click on the delete button in perticular row.
regards
yogesh
|
|
|
|
|
use DataKey property of the gridview to access the ID value and to delete a particular record set the Command Property of the Delete Button as "Delete" and use GridView.RowCommand Event and put your delete code there...
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
hello jon thanks for your reply but sorry its not working
i use a gridview then set the datakey property with the name of my primary key feild available in my table, then in row commnad event is used to display the value of datakey with the index it always display 1 as a result. so could you suggess any solution.
regards
yogesh
|
|
|
|
|
Did you set the datakeynames property in the GridView? something like this...
asp:gridview id="GridView1" datasourceid="GridView1Source" <br />
autogeneratecolumns="true" datakeynames="ID" runat="server">
If yes then In the GridView.RowCommand Event you can access the ID value using the below statement
GridView1.DataKeys[rowIndex].Value
try this...
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
Try this:
Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
Try
Dim oGridViewRow As GridViewRow
oGridViewRow = CType(CType(e.CommandSource, Control).NamingContainer, GridViewRow)
ID = CInt(GridView1.DataKeys(oGridViewRow.RowIndex).Value)
If e.CommandName = "DeleteTrans" Then
DeleteRecord(ID)'Function for delete the selected record
BindGridView()'Bind Gridview again
End If
Catch ex As Exception
End Try
End Sub
Hope this helps u??
|
|
|
|
|
you have to give a primary key field as datakey field of datagrid.
asp:DataGrid ID="dgrdProducts" DataKeyField="ProductID" OnDeleteCommand="dgrdProducts_DeleteCommand" Runat="Server"
.
.
Then in code file
void dgrdProducts_DeleteCommand( Object sender, DataGridCommandEventArgs e )
{
int intProductID;
intProductID = (int)dgrdProducts.DataKeys[e.Item.ItemIndex];
}
using intProductID you can delete record from database.
Regards,
EbyZ
|
|
|
|
|
I'm using VB.NET and Informix database
I'm trying to get last serial id whenever i perform an insert statement.
Here is what i have so far
Insert into Table1 values (0,"Mouse")
SELECT DBINFO('SQLCA.SQLERRD1') FROM systables WHERE tabname = Table1
My problem is, sometimes i get 0 as the ID although the row has been inserted
Can someone please help
Thanks
Read, Read, Read instead of asking Why, When, Who, and How?????
|
|
|
|
|
hi
i want to save my connection string in web.config . what is best way to encrypt and decrypt connection string ?
can you get me a good reference ?
tanks
|
|
|
|
|
|
|
You can refer to the help available with Visual Studio Web Developer Express Edition 2005. It has a walkthrough on encrypting and decrypting connection strings in web.config.
|
|
|
|
|
Hi,
Can anyone help me to open an instance of outlook with an attachment on click of button in a web page using C#?
Thanks in advance...
Sumithra Guturi
|
|
|
|
|
In my site I need to use ajax(HttpRequest class) to let the user go through a process . In order to use ajax I have employed some http handlers. I need the requirement of limiting access to my http handlers to just users that are in the related page. Is there anyway to limiting access to http handlers ? If you recommend that I have to use something other than http handlers I appreciate it .
Thanks in advance
|
|
|
|
|
How do u use IIS i'm totaly stuck
Anyone can help me
|
|
|
|
|
what do you want to do? Install? Configure?
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
I need to publish my site in my network
using IIS
|
|
|
|
|
Create a virtual directory in the IIS for your site and copy only the files that is needed to run the application.
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
You need nothing to do with IIS if you use Visual Studio 2005 the IIS is build in into environment and will automatically starts when you debug the webpage.
|
|
|
|
|
I need to publish my site in my network
using IIS
|
|
|
|
|
duo!@# wrote: I need to publish my site in my network
- Are you planning to publish your site on LAN or on Internet ?
If in LAN, copy your files to a network machine ( say server ). ASP.NET should be present in the server to get ASPX files executed. Goto IIS - > Default Website - > Create new virtual directory which points to your folder where files are stored. Now type URL like
http://SysName/VirtualDirectoryName/Filename.aspx
|
|
|
|
|
Hi all,
I have a problem in extracting data from xml file.
i have a data table which i assigned a xml file to it.
xml file contains products table and the query i need is
to get the prices > 100
i am trying this query
select * from products where price>100.
i want the above query to be used from xml file
i will appreciate if someone help me regarding this
|
|
|
|
|
use DataView.RowFilter Property. DataView will have the records based on the condition. Something like this...
Dim dv As DataView<br />
dv = DataTable.DefaultView<br />
dv.RowFilter = "product > 100"
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
Hello friends i have a XMl File for ads i want to calculate number of nodes
this xml file have So that i can repete my control but i don't know how to get total number of nodes in my xml Useing JAVASCRIPT
pls if any body know help me
Thanks in advance
|
|
|
|