1: Data binding
GridView supports data-binding data source formats, for example, you can use ObjectDataSource to bind data sources.
Dataset,datatable,list<t>, etc.
2: Column Binding
1) boundfield--generally directly binds the field corresponding to the data source, by specifying DataField to implement the binding.
2) checkboxfield--when the GridView control needs to present a CheckBox control, it is also bound to a bool type field by DataField.
3) hyperlinkfied--bound column implements hyperlink function, datanavigateurlfields= "ID" datanavigateurlformatstring= "xxx.aspx?id{0}"
4) ImageField,
5) ButtonField,
6) commandfield--command row and column template, built-in additions and deletions, selection and other functions (no specific use)
7) TemplateField--more flexible, generally by editing the column template can achieve the functions we need.
3:gridview-onrowdatabound Events
With this event we can specify a series of actions such as events for the bound columns
protected void Fslgridview1_rowdatabounding (object sender, GridViewRowEventArgs e)
{if (E.row.rowtype = = Datacontrolrowtype.datarow)
{
System.Data.DataRowView dv = (System.Data.DataRowView) E.row.dataitem;
String id = dv["id"]. ToString ();
Button btncheck = (button) E.row.findcontrol ("Btncheck");
Button Btnlook = (button) E.row.findcontrol ("Btnlook");
BTNCHECK.ATTRIBUTES.ADD ("onclick", "changevalue" + Btncheck.clientid + "', '" + ID + "'); return false");
}
}
4:gridview-onrowcommand Events
When we specify Commandname= "Linkdel" commandargument= ' <% #Eval ("ID")%> ' parameters for the controls inside the template column,
This event is triggered when we manipulate these controls. protected void Fslgridview2_rowcommand (object sender, Gridviewcommandeventargs e)
{
if (E.commandname = = "Linkdel")
{
if (e.commandargument = = null)
{
Return
}
String ID = E.commandargument.tostring ();
EVALUATEDATABLL BLL = new EVALUATEDATABLL ();
if (BLL. Deleterowdatabyid (ID))
{
Framework.Assistant.Web.ClientScriptHelper.WriteAlert ("Success", "Delete succeeded!") ");
Framework.Assistant.Web.ClientScriptHelper.RegisterScript ("Close", "CloseWindow (True);");
}
Else
{
Framework.Assistant.Web.ClientScriptHelper.WriteAlert ("Failure", "Delete failed, please correct and then re-operate!") ");
}
}
}
5:girdview the traversal of a control
foreach (GridViewRow item in this.) Fslgridview1.rows)
{
Todo:the things you want to do
}
6: Formatted Display of columns
<asp:templatefield headertext= "Content
<itemstyle width= "15%" horizontalalign= "Center"/>
<ItemTemplate>
<%# decryptinfocontent (Eval ("Infocontent"). ToString ())%>
</ItemTemplate>
</asp:TemplateField>
decryptinfocontent--Page Background method