PDA

View Full Version : datagrid footer



roya_dibaj
چهارشنبه 14 آذر 1386, 10:35 صبح
سلام دوستان من با asp.net2 with c# کار می کنم سوالم این است که آیا می توان توی footer datagrid فیلدی را از database نشان داد می خوام مثلا مجموع امتیاز های منو توی footer نشان دهد آیا این امکان را دارد اگر بله لطفا توضیح دهید.

abadanboy
چهارشنبه 14 آذر 1386, 13:05 عصر
آره می شه همون کاری رو که تو item template مکنی تو footer هم جواب میده
این کار رو من با repeater انجام دادم و مشکلی نداشت

roya_dibaj
چهارشنبه 14 آذر 1386, 13:45 عصر
دوست عزیز لطفا codeی که برای آوردن data به footer استفاده می شود را برایم ارسال کنید، چون که هر کاری می کنم درست نمی شود.

abadanboy
چهارشنبه 14 آذر 1386, 15:04 عصر
</ItemTemplate>
<FooterTemplate>
<tr bgcolor="#00337d" style="height:20px;">
<td width="15%">
<center>
<font color="#FFFFFF" face="Tahoma" size="2"><b>جمع کل</b></font>
</center>
</td>

</tr>
<tr bgcolor="#f8f5f1" style="height:20px;padding-top:10px">
<td valign="top" width="15%" style="text-align:right">
<center> <b><font face="Tahoma" color="#cc0076" size="1">

<asp:Label runat="server" ID="Label133"><%=plas %></asp:Label>
</font></b></center>
</td>

</tr>
</table>
</FooterTemplate>
</asp:Repeater>

c#


publicpartialclassPanel_Vam_Form : System.Web.UI.Page
{
SqlConnection cn = newSqlConnection();
publicint plas = 0;
protectedvoid Page_Load(object sender, EventArgs e)
{
Button1.Attributes.Add("onclick", "return a()");
if (Session["Logina"].ToString() == "no")
{
Response.Redirect("Login.aspx");
}
if (!IsPostBack)
{
PageSize.Value = "20";
CurrentPage.Value = "1";
// BuildGrid();
}
}
overrideprotectedvoid OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
// InitializeComponent();
cn.ConnectionString = Application["Con"].ToString();
base.OnInit(e);
}
publicvoid BuildGrid()
{
//Fill the DataSet
DataSet ds = newDataSet();
SqlDataAdapter myAdapter = newSqlDataAdapter("get_tblborrow_date", cn);
myAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;
myAdapter.SelectCommand.Parameters.Add("@sal1", SqlDbType.Int);
myAdapter.SelectCommand.Parameters.Add("@sal2", SqlDbType.Int);
myAdapter.SelectCommand.Parameters.Add("@mah1", SqlDbType.Int);
myAdapter.SelectCommand.Parameters.Add("@mah2", SqlDbType.Int);
myAdapter.SelectCommand.Parameters["@sal1"].Value = Dpsal.SelectedValue;
myAdapter.SelectCommand.Parameters["@sal2"].Value = Dpsalta.SelectedValue;
myAdapter.SelectCommand.Parameters["@mah1"].Value = DPmah.SelectedValue;
myAdapter.SelectCommand.Parameters["@mah2"].Value = Dpmahta.SelectedValue;

//Get the startRecord Count
//Remember database count is zero based so first decrease the value of
//the current page
//Fetch only the necessary records.
myAdapter.Fill(ds,"Products");
//DataBind the Repeater
int i = 0;
foreach (DataRow dr in ds.Tables["Products"].Rows)
{
i = ((int.Parse(dr[0].ToString().Trim()) + 35) - 25) / 25;
plas = plas + i;
}
rp.DataSource = ds.Tables["Products"].DefaultView;
rp.DataBind();
//Second Part
//Create a new Command to select the total number of records


}
publicvoid rpnd()
{



}
protectedvoid Button1_Click(object sender, EventArgs e)
{
BuildGrid();

Label4.Text = "";
P1.Visible = true;
if (rp.Items.Count == 0)
{
Label4.Text = "گزارشی یافت نشد";
P1.Visible = false;
}
}
}


کدهای c# را کامل واست گذاشتم ولی repeater فقط آخرش