Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Link on datafield in table cell

Status
Not open for further replies.

crxcte1

Programmer
May 22, 2003
74
US
I'm popluating a table through a query and using the control, <asp:BoundColumn DataField="ID" HeaderText="ID"></asp:BoundColumn>. I'm wanting to make the datafield ID a link to query all cells for that ID and display. Does .NET have a control for re-populating.
 
Fname1 works fine and the link works fine but having problems updating. How can I pass the ID to the query when using a link?

<Columns>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Save&#160;" CancelText="Cancel" EditText="Edit&amp;nbsp"></asp:EditCommandColumn>
<asp:ButtonColumn Text="Delete" CommandName="Delete"></asp:ButtonColumn>
<asp:BoundColumn DataField="ID" Visible=False HeaderText="ID"></asp:BoundColumn>
<asp:HyperLinkColumn Text="ID" HeaderText="ID" DataTextField="ID" DataNavigateUrlField="ID" DataNavigateUrlFormatString="SingleMember.aspx?ID={0}" Target="_parent"></asp:HyperLinkColumn>
<asp:BoundColumn DataField="Fname1" HeaderText="Fname1"></asp:BoundColumn>

//SCRIPT
void updateDataBase(Object s,DataGridCommandEventArgs e){
HyperLink ID = (HyperLink) e.Item.Cells[3].Controls[0];
TextBox Fname1 = (TextBox) e.Item.Cells[4].Controls[0];

//QUERY
string strSQL="UPDATE members set ";
if (Fname1.Text=="") {strSQL +="Fname1=\"Null\",";} else {strSQL +="Fname1='" + Fname1.Text + "' ";}
strSQL += "WHERE ID='" + ID + "';


Query on error:
UPDATE members set Fname1='Chris' WHERE ID=System.Web.UI.WebControls.HyperLink
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top