在 ajQGrid
中,当我双击一行时,我想打开另一个页面,其中显示有关所选行的更多数据。需要根据所选行构建查询并将其传递到该页面。MyjQGrid
是根据谁登录动态创建的。我是一名软件学生,我不知道该怎么做。我在网上搜索过,但一无所获。请你帮忙。如果您需要更多信息,请告诉我。
<trirand:JQGrid ID="JQGrid1" runat="server" Width="760px" onsearching="JQGrid1_Searching" >
<Columns>
</Columns>
<PagerSettings ScrollBarPaging="true" PageSize="100" NoRowsMessage="Scroll to bottom to retrieve new page" />
<AppearanceSettings HighlightRowsOnHover="true" />
<ToolBarSettings ShowAddButton="true" ShowSearchToolBar="true" ShowRefreshButton="true" />
<AddDialogSettings ReloadAfterSubmit="true" Caption="Add a new row" SubmitText="Add the row" Resizable="false" />
</trirand:JQGrid>
功能:
public static DataTable GetAnimalsByClient(Client cli)
{
DataTable dt = new DataTable();
try
{
MySqlConnection connection = Database.Connect();
string sql = string.Format("select a.animal_official_tag as AnimalOfficialTag, DATE_FORMAT(a.animal_date_of_birth,'%d/%m/%Y') AS DateOfBirth, a.animal_gender as AnimalGender, a.animal_breed as AnimalBreed, a.animal_jumbo as AnimalJumbo from animal a inner join herd_animal ha on a.animal_id = ha.animal_id join herd h on ha.herd_id = h.herd_id join client c on h.client_id = c.client_id where c.client_id = {0}", cli.ID);
MySqlDataAdapter adapter = new MySqlDataAdapter(sql, connection);
adapter.Fill(dt);
adapter.Dispose();
Database.Disconnect(connection);
}
catch (Exception exp)
{
StackFrame stackFrame = new StackFrame();
MethodBase methodBase = stackFrame.GetMethod();
Error.SaveError(methodBase.Name, exp.Message);
}
return dt;
}
public DataTable GetCurrentStock()
{
try
{
DataTable dt = (DataTable)AnimalDao.GetAnimalsByClient(UserSession.GetClient());
List<DataColumn> lstCol = new List<DataColumn>();
foreach (DataColumn col in dt.Columns)
{
lstCol.Add(col);
}
for (int i = 0; i < dt.Columns.Count; i++)
{
JQGridColumn col = new JQGridColumn();
col.DataField = lstCol[i].ColumnName;
col.HeaderText = lstCol[i].ColumnName;
col.Width = lstCol[i].ColumnName.Length;
col.Visible = true;
col.Editable = true;
JQGrid1.Columns.Add(col);
}
return dt;
}
catch (Exception exp)
{
return null;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!UserSession.LoggedIn())
{
Response.Redirect("Default.aspx");
}
RefreshGrid();
JQGrid1.DataSource = GetCurrentStock();
JQGrid1.DataBind();
}