---
title: "\"Fånga\" variabel som loopas fram i DataGrid?"
type: "forum-thread"
url: "https://www.webforum.nu/amne/dotnet/129156-fånga-variabel-som-loopas-fram-i-datagrid"
topic: ".NET"
topic_url: "https://www.webforum.nu/amne/dotnet"
author: "CokeLight"
published: "2005-05-30T14:32:34.000Z"
updated: "2005-05-30T14:32:34.000Z"
replies: 0
views: 167
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/dotnet/129156-fånga-variabel-som-loopas-fram-i-datagrid"
---

# "Fånga" variabel som loopas fram i DataGrid?

## #1 — CokeLight, 2005-05-30T14:32Z

Hejasan, det är if satsen jag har problem med, då jag inte vet hur jag lagrar {0} i en variabel som jag vill använda...?

```
if(!cl.isPublicServer())
{
	HyperLinkColumn hcPhoto = new HyperLinkColumn();
	hcPhoto.HeaderText = "Foto";
	hcPhoto.DataNavigateUrlField = "Foto";
	hcPhoto.DataNavigateUrlFormatString = "javascript:showImage('{0}');";
	hcPhoto.DataTextField = "foto"; 

	//[B]string photoName = {0};[/B] // --> Här blir det fel alltså... 

	//if(cl.FileExist("images/thumbNail", photoName, "jpg"))
		hcPhoto.DataTextFormatString = "<img src='images/thumbnail/{0}' border='0' width='18' height='22'>";
	//else
	//	hcPhoto.DataTextFormatString = "<img src='images/Genomskinlig.gif' border='0' width='18' height='22'>";
	
	hcPhoto.SortExpression = "foto";
	this.dgAllStaff.Columns.Add(hcPhoto);

	this.dgAllStaff.DataSource = dtc.CreateDataSource(this.getSpName(), this.RequestLetter, this.SortCriteria, this.SortDir);
	this.dgAllStaff.DataBind();
}
```

Permalänk: https://www.webforum.nu/p/129156

---

Tråden på webben: https://www.webforum.nu/amne/dotnet/129156-fånga-variabel-som-loopas-fram-i-datagrid
