الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

مشكلة في التصفح في gridview عند استخدام rowcommand

بدأه rauf911 في 18 فبراير 2012 · 3 رد · 548 مشاهدة · في ASP.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم ورحمة الله وبركاته

يا اخوان لدي مشكلة في التصفح (paging) في gridview وهي عندما أقوم بالضغط على رقم الصفحة التي اريد ان انتقل اليها في الgridview يحدث هناك خطأ وهو:

Input string was not in a correct format

ويظهر هذا الخطأ على الجملة

اقتباس

Dim index As Integer = Convert.ToInt32(e.CommandArgument)

وإليكم أكواد الgridview لمساعدتي في معرفة الخطأ وحله بإذن الله

اقتباس

<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"

BackColor="White" BorderColor="#333333" BorderStyle="Solid" BorderWidth="1px"

CellPadding="0" DataKeyNames="meet_no" DataSourceID="AccessDataSource2"

ForeColor="Black" GridLines="Vertical" Width="889px" AllowPaging="True"

style="font-weight: 700; text-align: center; vertical-align: middle;"

AllowSorting="True" HorizontalAlign="Center"

Caption="قائمة بالإجتماعات المغلقة" Font-Size="Small" PageSize="15">

<FooterStyle BackColor="#CCCC99" />

<RowStyle BackColor="#CCCCCC" />

<Columns>

<asp:BoundField DataField="meet_no"

SortExpression="meet_no" InsertVisible="False" ReadOnly="True" >

<ControlStyle BackColor="#333333" BorderColor="#333333" Font-Size="1pt"

ForeColor="#333333" Width="1px" Font-Names="Cordia New" />

<FooterStyle BackColor="#333333" BorderColor="#333333" Font-Size="1pt"

ForeColor="#333333" Width="1px" Font-Names="Cordia New" />

<HeaderStyle BackColor="#333333" BorderColor="#333333" Font-Bold="False"

Font-Size="1pt" ForeColor="#333333" Width="1px" Font-Names="Cordia New" />

<ItemStyle BackColor="#333333" BorderColor="#333333" Font-Size="1pt"

ForeColor="#333333" Width="1px" Font-Names="Cordia New" />

</asp:BoundField>

<asp:TemplateField HeaderText="الموضوع" SortExpression="meet_subj">

<EditItemTemplate>

<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("meet_subj") %>'></asp:TextBox>

</EditItemTemplate>

<ItemTemplate>

<asp:LinkButton ID="Label1" runat="server" Text='<%# Bind("meet_subj") %>'></asp:LinkButton>

</ItemTemplate>

</asp:TemplateField>

<asp:BoundField DataField="meet_main_dept" HeaderText="الإدارة المنظمة"

SortExpression="meet_main_dept" >

<ControlStyle Width="105px" />

<FooterStyle Width="105px" />

<HeaderStyle Width="105px" />

<ItemStyle Width="105px" />

</asp:BoundField>

<asp:BoundField DataField="meet_date" HeaderText="التاريخ"

SortExpression="meet_date" DataFormatString="{0:MM-dd-yyyy}" >

<ControlStyle Width="70px" />

<FooterStyle Width="65px" />

<HeaderStyle Width="65px" />

<ItemStyle Width="70px" />

</asp:BoundField>

<asp:BoundField DataField="meet_time" HeaderText="الوقت"

SortExpression="meet_time" DataFormatString="{0:t}" >

<ControlStyle Width="60px" />

<FooterStyle Width="60px" />

<HeaderStyle Width="60px" />

<ItemStyle Width="60px" />

</asp:BoundField>

<asp:BoundField DataField="duration" HeaderText="المدة"

SortExpression="duration" >

<ControlStyle Width="30px" />

<FooterStyle Width="30px" />

<HeaderStyle Width="30px" />

<ItemStyle Width="30px" />

</asp:BoundField>

<asp:BoundField DataField="meet_location" HeaderText="المكان"

SortExpression="meet_location" >

<ControlStyle Width="95px" />

<FooterStyle Width="95px" />

<HeaderStyle Width="95px" />

<ItemStyle Width="95px" />

</asp:BoundField>

</Columns>

<PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" />

<SelectedRowStyle BackColor="#666666" Font-Bold="True" ForeColor="White" />

<HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />

<AlternatingRowStyle BackColor="White" />

</asp:GridView>

أما كود الvb فهو:

اقتباس

Protected Sub GridView2_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView2.RowCommand

Dim index As Integer = Convert.ToInt32(e.CommandArgument)

Dim row As GridViewRow = GridView2.Rows(index)

Session("ddlValue3") = CType(row.Cells(0), DataControlFieldCell).Text

Session("subject") = CType(row.Cells(1), DataControlFieldCell).Text

Dim lb As LinkButton = CType(e.CommandSource, LinkButton)

Response.Redirect("closed_meet.aspx?meet_subj=" + lb.Text) 'redirecting

End Sub

أرجو مساعدتي وجزاكم الله خيراً

تم تعديل هذه المشاركة بواسطة rauf911 في 18 فبراير 2012 في 12:25

#2

جرب هذا الكود

Dim index As string = e.CommandArgument
#3

أخي الكريم جزاك الله خيراً

لقد قمت بتجربة الكود و ظهر الخطأ التالي :-

Conversion from string "" to type 'Integer' is not valid.

على الكود:-

اقتباس

Dim row As GridViewRow = GridView2.Rows(index)

أرجو مساعدتي يا اخوان

وجزاكم الله خيراً

#4

جرب هذا الكود

Protected Sub GridView2_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView2.RowCommand

        Dim row As GridViewRow = DirectCast(DirectCast(e.CommandSource, LinkButton).Parent.Parent, GridViewRow)

        Session("ddlValue3") = CType(row.Cells(0), DataControlFieldCell).Text

        Session("subject") = CType(row.Cells(1), DataControlFieldCell).Text

        Dim lb As LinkButton = CType(e.CommandSource, LinkButton)

        Response.Redirect("closed_meet.aspx?meet_subj=" + lb.Text) 'redirecting

    End Sub

مواضيع مشابهة