本文整理汇总了C#中Grid.State方法的典型用法代码示例。如果您正苦于以下问题:C# Grid.State方法的具体用法?C# Grid.State怎么用?C# Grid.State使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Grid
的用法示例。
在下文中一共展示了Grid.State方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSelectedRows
internal static void GetSelectedRows(Grid grid)
{
if (HttpContext.Current.Request[grid.ClientID + "checkboxes"] == null)
return;
StringBuilder oldRowsBuilder = new StringBuilder();
if (grid.GetState("SelectedRows") != null)
oldRowsBuilder.Append(grid.GetState("SelectedRows").ToString());
StringBuilder selectedRowsBuilder = new StringBuilder();
foreach (string request in HttpContext.Current.Request[grid.ClientID + "checkboxes"].Split('!'))
{
if (string.IsNullOrEmpty(request) == false)
oldRowsBuilder = new StringBuilder(oldRowsBuilder.ToString().Replace(request + "!", string.Empty));
if (Grid.GotHttpContext && HttpContext.Current.Request[string.Format("{0}_{1}", grid.ClientID, request)] != null)
selectedRowsBuilder.AppendFormat("{0}!", request);
}
grid.State("SelectedRows", oldRowsBuilder + selectedRowsBuilder.ToString());
}
示例2: CreateFilterByColumns
internal static void CreateFilterByColumns(Grid grid, WebGridHtmlWriter writer, int[] sortedColumnID)
{
grid.m_RowsAdded++;
writer.Write(
grid.IsUsingJQueryUICSSFramework
? "<tr class=\"ui-widget wgrow\" id=\"{0}r{1}\">"
: "<tr class=\"wgrow\" id=\"{0}r{1}\">", grid.ID, grid.m_RowsAdded);
for (int ii = 0; ii < sortedColumnID.Length; ii++)
{
Column column = grid.MasterTable.Columns[sortedColumnID[ii]];
if (column.FilterByColumnCollection.Count == 0)
{
string columnstyle = string.Empty;
string columnId = string.Format(" id=\"{0}{1}r{2}\"", grid.ID, column.ColumnId, grid.m_RowsAdded);
if (grid.MasterTable.Columns[column.ColumnId].WidthColumnHeaderTitle != Unit.Empty)
columnstyle =
string.Format("style=\"width: {0};\"",
grid.MasterTable.Columns[column.ColumnId].WidthColumnHeaderTitle);
writer.Write("<th {0} {1}> </th>", columnstyle,columnId);
continue;
}
ColumnHeader addcolumn = new ColumnHeader
{
m_Class = string.Format("{0} wggridcell", column.CssClassTitle),
m_Align = column.GridAlign,
m_VAlign = VerticalPosition.bottom,
m_ColumnWidth =
grid.MasterTable.Columns[column.ColumnId].WidthColumnHeaderTitle,
m_GridRowCount = grid.m_RowsAdded,
m_GridId = grid.ID
};
addcolumn.RenderBeginTag(writer,column,null,"<th");
string selectedValue = null;
if (Grid.GotHttpContext &&
HttpContext.Current.Request.Form[string.Format("ddl{0}", column.ClientHeaderId)] != null)
{
selectedValue =
HttpUtility.HtmlEncode(
HttpContext.Current.Request.Form[string.Format("ddl{0}", column.ClientHeaderId)]);
grid.State(string.Format("ddl{0}", column.ClientHeaderId), selectedValue);
}
else if (grid.GetState(string.Format("ddl{0}", column.ClientHeaderId)) != null)
selectedValue = grid.GetState(string.Format("ddl{0}", column.ClientHeaderId)) as string;
bool isdate = false;
if (grid.MasterTable.Columns[column.ColumnId].ColumnType == ColumnType.DateTime)
isdate = true;
string eventScript = string.Empty;
if (grid.Page != null)
{
string link = grid.EnableCallBack && !column.ForcePostBack ? Asynchronous.GetCallbackEventReference(grid,
string.Format("ElementPostBack!ddl{0}",
column.ColumnId), false,
string.Empty, string.Empty) : grid.Page.ClientScript.GetPostBackEventReference(grid,
string.Format("ElementPostBack!ddl{0}",
column.ColumnId));
eventScript = string.Format(" onchange=\"{0}\" ", link);
}
string style = grid.MasterTable.Columns[column.ColumnId].WidthColumnHeaderTitle != Unit.Empty ? "class=\"wgeditfield wgselectbox \"" : " class=\"wgeditfield wgselectbox \" ";
if (!isdate)
{
StringBuilder dropdownbox = new StringBuilder("<select ");
dropdownbox.AppendFormat("{0} name=\"ddl{1}\" id=\"ddl{1}\" {2}><option value=\"\" selected=\"selected\">{3}</option>", style, column.ClientHeaderId, eventScript, column.Grid.GetSystemMessage("EmptySearchFilter"));
if (grid.Scripts == null || !grid.Scripts.DisableSelectMenu)
Grid.AddClientScript(writer, string.Format("$(document).ready(function() {{$('#ddl{0}').selectmenu({{maxHeight: {2},style:'dropdown',width: {1}}});}});", column.ClientHeaderId, column.WidthColumnHeaderTitle.Value, 400));
int i = 0;
while (i < column.FilterByColumnCollection.Count)
{
string _value = HttpUtility.HtmlEncode(column.FilterByColumnCollection[i]);
string _title = HttpUtility.HtmlEncode(column.FilterByColumnCollection.GetKey(i));
if (selectedValue != null && selectedValue == _value)
dropdownbox.AppendFormat("<option selected=\"selected\" value=\"{0}\">{1}</option>",
HttpUtility.HtmlEncode(column.FilterByColumnCollection[i]), _title);
else
dropdownbox.AppendFormat("<option value=\"{0}\">{1}</option>",
HttpUtility.HtmlEncode(column.FilterByColumnCollection[i]), _title);
i++;
}
writer.Write(dropdownbox);
writer.Write("</select> ");
}
else
{
if (grid.DatabaseConnectionType != DataBaseConnectionType.SqlConnection)
throw new GridException(
string.Format("'FilterByColumn' property for 'DateTime' ({0}) columns are only supported by 'SqlConnection' connection strings.", column.ColumnId));
writer.Write("<span style=\"white-space: nowrap;vertical-align:middle;\">");
string filter = ((WebGrid.DateTime)grid.MasterTable.Columns[column.ColumnId]).SearchFilter;
if (string.IsNullOrEmpty(filter))
{
//.........这里部分代码省略.........