473,669 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Gridview - visual basic - need to know which row contains the clickedbutton.

All -

Thanks in advance for any help you can provide. I've been working with
a GridView in Visual Basic for a long time trying to get a list of
contacts and to be able to edit and delete the contacts as well as
send email on behalf of hte contact. I originally started with the
built in update/delete functions of the gridview but I could never get
them to work... then I created new pages that are launched on button
clicks as shown below. I'm using javascript so that the code can be
run client-side.

This actually was working, but I found that if I had more than one
contact the contactID would always be determined to be the last
contact in the list.

I had the code-behind (which I believe used the OnRowDataBound event),
but in trying to solve this issue a number of ways I think I must have
lost it.

Can anyone please, please tell me how I can know what row is clicked
when the user clicks one of the buttons below? This is fairly time
sensitive and is also outside the scope of my normal job so I'm in the
crunch of needing something fairly quickly on a number of levels. I'm
also fairly new to all this - it's an ugly combination.

Thanks
Danielle

<asp:GridView ID="gdContacts " runat="server"
AutoGenerateCol umns="False"
AllowSorting="T rue"
BackColor="#FFE A97"
CellPadding="6"
DataKeyNames="I D,Guid,ContactE mail"
DataSourceID="s qlContactInfo"
EmptyDataText = "<None>"
Font-Names="Verdana"
Font-Size="Small">
<Columns>
<asp:TemplateFi eld HeaderText="Con tact Name"
SortExpression= "ContactNam e">
<EditItemTempla te>
<asp:TextBox ID="txtContactN ame"
runat="server" Text='<%# Bind("ContactNa me") %>'></asp:TextBox>
</EditItemTemplat e>
<ItemTemplate >
<asp:Label ID="Label1" runat="server" Text='<
%# Bind("ContactNa me") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Con tact Email"
SortExpression= "ContactEma il">
<EditItemTempla te>
<asp:TextBox ID="txtContactE mail"
runat="server" Text='<%# Bind("ContactEm ail") %>'></asp:TextBox>
</EditItemTemplat e>
<ItemTemplate >
<asp:Label ID="Label2" runat="server" Text='<
%# Bind("ContactEm ail") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Con tact Phone"
SortExpression= "ContactPho ne">
<EditItemTempla te>
<asp:TextBox ID="txtContactP hone"
runat="server" Text='<%# Bind("ContactPh one") %>'></asp:TextBox>
</EditItemTemplat e>
<ItemTemplate >
<asp:Label ID="Label3" runat="server" Text='<
%# Bind("ContactPh one") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="ID"
InsertVisible=" False" Visible="False" >
<EditItemTempla te>
<asp:TextBox ID="txtID" runat="server" Text='<
%# Bind("ID") %>'></asp:TextBox>
</EditItemTemplat e>
<ItemTemplate >
<asp:Label ID="lblID" runat="server" Text='<%#
Bind("ID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Gui d"
InsertVisible=" False" Visible="False" >
<EditItemTempla te>
<asp:TextBox ID="txtGuid" runat="server"
Text='<%# Bind("Guid") %>'></asp:TextBox>
</EditItemTemplat e>
<ItemTemplate >
<asp:Label ID="lblGuid" runat="server" Text='<
%# Bind("Guid") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld ShowHeader="Fal se">
<ItemTemplate >
<input type="button" onclick="window .open('./
Edit.aspx?ID=<% =CStr(contactID )%>');" value="Edit" />
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld ShowHeader="Fal se">
<ItemTemplate >
<input type="button" onclick="window .open('./
Delete.aspx?ID= <%=CStr(contact ID)%>');" value="Delete" />
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld ShowHeader="Fal se">
<ItemTemplate >
<input type="button"
onclick="window .open('mailto:d d@xyz.com?subje ct=Test
Message&body=Ag reement Guid: <%=CStr(agreeme ntID)%>');" value="Submit
Case" />
</ItemTemplate>
</asp:TemplateFie ld>
</Columns>
<HeaderStyle BackColor="Blac k" ForeColor="Whit e" />
<AlternatingRow Style BackColor="#FFE 16D" />
</asp:GridView>
<asp:SqlDataSou rce ID="sqlContactI nfo" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:ConnectionSt ring_Stage %>"
SelectCommand=" usp_Get_Stuff"
SelectCommandTy pe="StoredProce dure" >
<SelectParamete rs>
<asp:QueryStrin gParameter Name="agreement Guid"
QueryStringFiel d="agreementGui d" Type="String" />
</SelectParameter s>

</asp:SqlDataSour ce>
Jun 27 '08 #1
2 1484
My suggestion is to use a FormView to do the actual updates. Then you can
set up the insert query without the autogenerated field and you should be
fine.

I should have an example from Expression Web that is pure drag and drop. If
I can find it rather quickly, I will post something, as the instructions are
actually rather simple.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

*************** *************** **************
| Think outside the box! |
*************** *************** **************
"Danielle" <wx****@aol.com wrote in message
news:e7******** *************** ***********@w7g 2000hsa.googleg roups.com...
All -

Thanks in advance for any help you can provide. I've been working with
a GridView in Visual Basic for a long time trying to get a list of
contacts and to be able to edit and delete the contacts as well as
send email on behalf of hte contact. I originally started with the
built in update/delete functions of the gridview but I could never get
them to work... then I created new pages that are launched on button
clicks as shown below. I'm using javascript so that the code can be
run client-side.

This actually was working, but I found that if I had more than one
contact the contactID would always be determined to be the last
contact in the list.

I had the code-behind (which I believe used the OnRowDataBound event),
but in trying to solve this issue a number of ways I think I must have
lost it.

Can anyone please, please tell me how I can know what row is clicked
when the user clicks one of the buttons below? This is fairly time
sensitive and is also outside the scope of my normal job so I'm in the
crunch of needing something fairly quickly on a number of levels. I'm
also fairly new to all this - it's an ugly combination.

Thanks
Danielle

<asp:GridView ID="gdContacts " runat="server"
AutoGenerateCol umns="False"
AllowSorting="T rue"
BackColor="#FFE A97"
CellPadding="6"
DataKeyNames="I D,Guid,ContactE mail"
DataSourceID="s qlContactInfo"
EmptyDataText = "<None>"
Font-Names="Verdana"
Font-Size="Small">
<Columns>
<asp:TemplateFi eld HeaderText="Con tact Name"
SortExpression= "ContactNam e">
<EditItemTempla te>
<asp:TextBox ID="txtContactN ame"
runat="server" Text='<%# Bind("ContactNa me") %>'></asp:TextBox>
</EditItemTemplat e>
<ItemTemplate >
<asp:Label ID="Label1" runat="server" Text='<
%# Bind("ContactNa me") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Con tact Email"
SortExpression= "ContactEma il">
<EditItemTempla te>
<asp:TextBox ID="txtContactE mail"
runat="server" Text='<%# Bind("ContactEm ail") %>'></asp:TextBox>
</EditItemTemplat e>
<ItemTemplate >
<asp:Label ID="Label2" runat="server" Text='<
%# Bind("ContactEm ail") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Con tact Phone"
SortExpression= "ContactPho ne">
<EditItemTempla te>
<asp:TextBox ID="txtContactP hone"
runat="server" Text='<%# Bind("ContactPh one") %>'></asp:TextBox>
</EditItemTemplat e>
<ItemTemplate >
<asp:Label ID="Label3" runat="server" Text='<
%# Bind("ContactPh one") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="ID"
InsertVisible=" False" Visible="False" >
<EditItemTempla te>
<asp:TextBox ID="txtID" runat="server" Text='<
%# Bind("ID") %>'></asp:TextBox>
</EditItemTemplat e>
<ItemTemplate >
<asp:Label ID="lblID" runat="server" Text='<%#
Bind("ID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Gui d"
InsertVisible=" False" Visible="False" >
<EditItemTempla te>
<asp:TextBox ID="txtGuid" runat="server"
Text='<%# Bind("Guid") %>'></asp:TextBox>
</EditItemTemplat e>
<ItemTemplate >
<asp:Label ID="lblGuid" runat="server" Text='<
%# Bind("Guid") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld ShowHeader="Fal se">
<ItemTemplate >
<input type="button" onclick="window .open('./
Edit.aspx?ID=<% =CStr(contactID )%>');" value="Edit" />
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld ShowHeader="Fal se">
<ItemTemplate >
<input type="button" onclick="window .open('./
Delete.aspx?ID= <%=CStr(contact ID)%>');" value="Delete" />
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld ShowHeader="Fal se">
<ItemTemplate >
<input type="button"
onclick="window .open('mailto:d d@xyz.com?subje ct=Test
Message&body=Ag reement Guid: <%=CStr(agreeme ntID)%>');" value="Submit
Case" />
</ItemTemplate>
</asp:TemplateFie ld>
</Columns>
<HeaderStyle BackColor="Blac k" ForeColor="Whit e" />
<AlternatingRow Style BackColor="#FFE 16D" />
</asp:GridView>
<asp:SqlDataSou rce ID="sqlContactI nfo" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:ConnectionSt ring_Stage %>"
SelectCommand=" usp_Get_Stuff"
SelectCommandTy pe="StoredProce dure" >
<SelectParamete rs>
<asp:QueryStrin gParameter Name="agreement Guid"
QueryStringFiel d="agreementGui d" Type="String" />
</SelectParameter s>

</asp:SqlDataSour ce>
Jun 27 '08 #2
Gregory -

If you can find something I'd be really appreciative.

Thanks :-)
Danielle
Jun 27 '08 #3

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

Similar topics

3
13741
by: NateDawg | last post by:
I'm reposting this. I'm kinda in a bind untill i get this figured out, so if anyone has some input it would sure help me out. Ok, I’ve noticed a few gridview problems floating around the forum. Everyone wants to do a java confirmation box when a user clicks the delete button. Fair enough, basic user design rules state that you should always confirm a delete action. There is also a consensus that the best way to do this is a template...
7
14802
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I want to look at that data and filter it based on what is in it. I know that this could have been done with data sets and data views in asp.net 1.1 but how is this done now in asp.net 2.0?
3
19336
by: Martin | last post by:
Hi, I have a very frustrating problem that I have researched for countless hours to no avail. There are many posts asking very similar things, however none usefull in my situation. I am using VS 2005 (ASP 2.0) and VB .NET. I have a page with a datalist, a gridview and then other data controls, nested in that order. This all works great, and produces a nice looking page, but I cannot for the life of me figure out how to reference
5
6436
by: sutphinwb | last post by:
Hi - This could be a simple question. When I relate two tables in a datasetet, how do I get that relation to show up in a GridView? The only way I've done it, is to create a separate table in the dataset with a join query for the GetData() select method. I use ObjectDataStore to couple the GridView with the table adapter on the dataset. If I point the ODS at the child table, the GridView will bind to the "normal" select and I end up...
4
2155
by: sqlguy | last post by:
Why do we have to contact MS for a problem that has been with this compiler from at least the beta of VS 20005. I am so sick and tired of the 30 - 40 clicks it takes to dismiss VS when there is a problem. Can they not just post the fix. I see no reason to contact MS since I have most likely sent about 1500 dumps to them and I would think this would get their attention.
97
5487
by: Master Programmer | last post by:
An friend insider told me that VB is to be killled off within 18 months. I guess this makes sence now that C# is here. I believe it and am actualy surprised they ever even included it in VS 2003 in the first place. Anyone else heard about this development? The Master
5
270
by: brian | last post by:
I have a gridview that will contain 5000 + rows that is initially loaded into a dataset and bound to a gridview. On the form I have textboxes and dropdown list's I use to let the user fill in and click an add button to add new records. As I let users add records I update the SQL backend (insert a record). I want to programattically add a row to the gridview an not having to requery the table reload the dataset and bind each time a...
4
8823
by: Peter | last post by:
I want to call a JavaScript on PageIndexChanged event, how do I do that? Thank You Peter
6
2515
by: ahling | last post by:
Hi, I have a question to ask regarding the gridview control in visual basic 2008. How to bound data to the gridview control? I tried to link the gridview to the sqlsourcedata but after linking, I realised that the words in the rows and columns (not including the header) showed me 'abc' instead of 'databound'. This abc means that I did not link my gridview to the sqlsourcedata properly? I don't know... And, how to ensure that when I...
0
8465
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8895
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8809
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7407
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6210
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4386
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2032
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.