In a hyperlink column of gridview, suppose the value of the property DataNavigateUrlFormatString is “ProductsForSupplierDetails.aspx?SupplierID={0}”. Many people think that the argument {0} is replaced by the value of the property DataKeyNames of the Gridview. But in actual case this is replaced by the value of the property DataNavigateUrlFields of the hyperlink column.
Now suppose you want to pass two arguments instead of one, something like this “ProductsForSupplierDetails.aspx?SupplierID={0}&CompanyName={1}”.
Now as these two arguments come from property DataNavigateUrlFields of the hyperlink column. So value of this property has to be “DataNavigateUrlFields="SupplierID,CompanyName”.
At run time the .NET replaces {0} with “SupplierID” and {1} with “CompanyName” of that row.
Pretty simple and straightforward it seems but I have seen many people struggling with this simple concept. Also I found wrong answers for this problem in some .NET forums. Hence thought to post it here for benefit of masses.
Now suppose you want to pass two arguments instead of one, something like this “ProductsForSupplierDetails.aspx?SupplierID={0}&CompanyName={1}”.
Now as these two arguments come from property DataNavigateUrlFields of the hyperlink column. So value of this property has to be “DataNavigateUrlFields="SupplierID,CompanyName”.
At run time the .NET replaces {0} with “SupplierID” and {1} with “CompanyName” of that row.
5 comments:
nice article! Thanks
It is remarkable, rather valuable idea
Remarkable phrase and it is duly
Bravo, what necessary words..., an excellent idea
Post a Comment