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>