Articles in the GridView Tips Category
ASP.Net, GridView Tips, Tech Corner »
Binding Images to a Gridview has been explained in this article. For this , first start a new application with ASP.NET and drop a GridView control onto the aspx page.Now add a new template Column to the GridView.In addition,if you want to display anything else, add bound fields or template fields according to your needs.In here, i have used a bound fied to display the image Id and the template field to display the Image.Now In the template field,add an Image control as the item template.For this just click on …
Read the full Post »ASP.Net, GridView Tips, Tech Corner »
How to use a dropdownlist in a gridview??
I will try explain this with best of my knowledge, the use of a dropdownlist inside comes when the case of edit update in a gridview comes. Consider an Eg:
A gridview that displays a “name” and a “Country”, and an option to edit the Country of a person. This is done from a dropdownlist.
Initial Requirements:
1)
Tables(Ms sqlserver2008 is the back end database used in here)
Table name:- country_lloyd
CountryId int
CountryName varchar(50)
Table name:- …
ASP.Net, GridView Tips, Tech Corner »
Sometimes we might be in a situation where we need to fill a gridview from the Client itself and not from the database
for eg:-filling a gridview with values entered into a textbox.
For this we need to provide as data source a datatable that will fill based on the values we enter.
Declare as global or in the BLL(if you are using N-Tier Structure)
public static DataTable TempTable;
Global Varaible
DataRow Dtr;
Create Structure of the datatable
private void CreateStructure()
{
TempTable = new DataTable(”DatatableName”);
TempTable.Columns.Add(”ColumnName”, typeof(datatype));//eg-TempTable.Columns.Add(”Name”, typeof(string))
..add more..
}
Now to Fill the GridView
private void FillGrid()
{
Dtr = TempTable.NewRow();
Dtr["ColumnName"] = Textbox1.text;
..add the …
ASP.Net, GridView Tips, Tech Corner »
I am posting this one with a notion that the readers do have a little bit knowledge about dot net.Hope it helps.
Pre-requisites
Add a gridview(gdvw_Sample) to your ‘Default.aspx’ page,
Bind the gridview with values from a table in the database.
Remove “AutoGenerate Columns” of gridview.
Add two “boundfields”.
Set the primary key of the table as the “datakey” of the gridview.
Add a “command field-Edit Update Cancel”.
How to set the datakey and BoundFields???
Copying the Html code below will create a gridview with 2 boundfields Name ,Address and datakey as Id.
<asp:GridView ID=”gdvw_Sample” runat=”server” …