PDA

View Full Version : مشکل در pagging



farideh_en
چهارشنبه 27 تیر 1386, 14:24 عصر
با سلام
من یک برنامه ای با #c نوشتم و pagging را انجام دادم و فقط مشکلم در ایجاد button و یا Hyperlink است و می خوام از طریق کد در یک حلقه به تعداد صفحات button و یا Hyperlink ایجاد کنم و در رویداد click یا command به یک متدی را که شامل واکشی رکورد ها از جدول هست پارامتر ها را ارسال کنم و متد را فراخوانی کنم ولی طریقه انجام این کار از طریق کد را نمی دونم.

najafzade
چهارشنبه 27 تیر 1386, 14:27 عصر
ورژن C# تون چنده؟:عصبانی++:

farideh_en
چهارشنبه 27 تیر 1386, 14:33 عصر
من از VS 2005 استفاده می کنم .من button و یا Hyperlink را ایجاد می کنم ولی نمی دونم چطور از commandname و command استفاده کنم؟

majid.nozad
پنج شنبه 25 مرداد 1386, 22:18 عصر
این کد asp گرید


<asp:GridView ID="MyGrid" runat="server" AllowPaging="True" AutoGenerateColumns="False"
CellPadding="3" CssClass="grid" DataKeyNames="NewsId" Width="750px">
<FooterStyle BackColor="Black" ForeColor="#000066" />
<Columns>
<asp:ButtonField CommandName="Select" Visible="False" />
<asp:ImageField DataAlternateTextField="Active" DataImageUrlField="Active" DataImageUrlFormatString="../images/act{0}.png"
HeaderText="فعال">
<ItemStyle CssClass ="be_center" Width="30px" HorizontalAlign ="Center" />
<HeaderStyle CssClass="GridHeaderText" HorizontalAlign="Center" />
</asp:ImageField>
<asp:ImageField DataAlternateTextField="ispic" DataImageUrlField="ispic" DataImageUrlFormatString="../images/act{0}.png"
HeaderText="تصویر">
<ItemStyle CssClass ="be_center" Width="30px" />
<HeaderStyle CssClass="GridHeaderText" HorizontalAlign="Center" />
</asp:ImageField>

<asp:BoundField DataField="CreateDdate" HeaderText="تاریخ" >
<ItemStyle Width="70px" />
<HeaderStyle CssClass="GridHeaderText" HorizontalAlign="Right" />
</asp:BoundField>
<asp:BoundField DataField="newstitle" HeaderText="عنوان" >
<HeaderStyle CssClass="GridHeaderText" HorizontalAlign="Right" />
</asp:BoundField>
<asp:ButtonField HeaderText="حذف تصویر" ButtonType="Image" ImageUrl="../images/del.png" CommandName="Del_pic" >
<ItemStyle CssClass ="be_center" Width="60px" />

<HeaderStyle CssClass="GridHeaderText" HorizontalAlign="Center" />
</asp:ButtonField>
<asp:ButtonField ButtonType="Image" HeaderText="ویرایش" ImageUrl="../images/run.png" CommandName="Edit_Agahi">
<ItemStyle CssClass ="be_center" Width="60px" />
<HeaderStyle CssClass="GridHeaderText" HorizontalAlign="Center" />
</asp:ButtonField>
<asp:ButtonField HeaderText="حذف آگهی" ButtonType="Image" ImageUrl="../images/del.png" CommandName="Del_agahi" >
<ItemStyle CssClass ="be_center" Width="60px" />

<HeaderStyle CssClass="GridHeaderText" HorizontalAlign="Center" />
</asp:ButtonField>
<asp:ButtonField HeaderText="تغییر وضعیت" ButtonType="Image" ImageUrl="../images/change.png" CommandName="Change_stat" >
<ItemStyle CssClass ="be_center" Width="65px" />
<HeaderStyle CssClass="GridHeaderText" HorizontalAlign="Center" />
</asp:ButtonField>
</Columns>
<RowStyle CssClass="row_style" ForeColor="#000066" />
<EditRowStyle CssClass="Selected_row" />
<SelectedRowStyle CssClass="Selected_row" />
<PagerStyle BackColor="White" CssClass="FooterCell" ForeColor="#000066" Height="15px"
HorizontalAlign="Left" />
<HeaderStyle CssClass="HeadingCell " Font-Bold="False" />
<AlternatingRowStyle CssClass="Grid_Alternate" />
</asp:GridView>




اینم کد کنترل دکمه ها در vb



Protected Sub MyGrid_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs ) Handles MyGrid.RowCommand
' Dim row As GridViewRow = CType(CType(e.CommandSource, Control).NamingContainer, GridViewRow)

'ID = MyGrid.DataKeys(row.RowIndex).Value
Dim Dk As DataKey = CType(sender, GridView).DataKeys(e.CommandArgument)
ID = Dk.Value
Select Case e.CommandName

Case "Del_agahi"


db.Exec_Command("delete from news where NewsID=" & ID)


Case "Del_pic"



Dim pic(0) As Byte
Dim cmd As String = "Update News Set IsPic=0 , newsPic= @newsPic Where newsID= " & ID.ToString
db.exec_by_Picparam(cmd, pic)

Case "Change_stat"

Dim act As Boolean
Dim dt As DataSet
dt = db.GetDataset("select active from news where newsid=" & ID)

act = dt.Tables(0).Rows(0).Item(0)

If act Then
db.Exec_Command("update News set active=0 WHERE newsID = '" + ID.ToString + "'")
Else
db.Exec_Command("update News set active=1 WHERE newsID = '" + ID.ToString + "'")
End If

Case "Edit_Agahi"


Dim dt As DataSet
dt = db.GetDataset("select NewsId,Active,Ispic,CreatedDate,NewsTitle,Descript ion,topic from news where newsid=" & ID)

lbl_temp.Text = dt.Tables(0).Rows(0).Item("NewsId").ToString()
txtTitle.Text = dt.Tables(0).Rows(0).Item("NewsTitle").ToString()
Dim strbTopic As StringBuilder = New StringBuilder(dt.Tables(0).Rows(0).Item("topic").ToString())
strbTopic.Replace("<br>", vbCrLf)
txtTopic.Text = strbTopic.ToString()
Dim strbDes As StringBuilder = New StringBuilder(dt.Tables(0).Rows(0).Item("Description").ToString())
strbDes.Replace("<br>", vbCrLf)
txtDiscription.Text = strbDes.ToString()
txtCreatedDate.Text = dt.Tables(0).Rows(0).Item("CreatedDate").ToString()
chkActive.Checked = dt.Tables(0).Rows(0).Item("Active").ToString()

Btn_Edit.Enabled = True
Btn_Insert.Enabled = False
Btn_New.Enabled = True


End Select

BindData()

End Sub