hi all ,
i have gridview have 6 columns on of these column is checklistbox in editetemplate and in itemtemplate ,
the datasource of checklistbox in itemptemplate is diffrent of the the datasource in edittemplate
the problem is in page load when binding gridview the gridview is appear with an empty row and then another row empty from all cells except column having checklist
then row all cells having value but checklist column is empty
how can i fix this
i want all cells appear in the same row with their values
this is my grid view code :
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
BackColor="White" BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px"
CellPadding="4">
<Columns>
<asp:TemplateField HeaderText="نوع التعليم">
<EditItemTemplate>
<asp:Label ID="lbl_edu_type" runat="server" Text='<%# Bind("edu_type_id") %>'></asp:Label>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("edu_type_id") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="رقم الترخيص">
<EditItemTemplate>
<asp:Label ID="lblold_number" runat="server"
Text='<%# Bind("old_lisense_number") %>'></asp:Label>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("old_lisense_number") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="تاريخ تأسيس المدرسه ">
<EditItemTemplate>
<asp:TextBox ID="txtold_lisense_date" runat="server"
Text='<%# Bind("old_lisense_date") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("old_lisense_date") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="تاريخ بداية الرخصه الحاليه ">
<EditItemTemplate>
<asp:TextBox ID="txtold_start_lisense_date" runat="server"
Text='<%# Bind("lisenses_date") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("lisenses_date") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="تاريخ نهاية الرخصه الحاليه ">
<EditItemTemplate>
<asp:TextBox ID="txt_current_old_lisense_date" runat="server"
Text='<%# Bind("lisensee_date") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Bind("lisensee_date") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="المراحل الدراسيه ">
<EditItemTemplate>
<asp:CheckBoxList ID="chlist_edit" runat="server" RepeatColumns="3">
</asp:CheckBoxList>
</EditItemTemplate>
<ItemTemplate>
<asp:CheckBoxList ID="chlist_item" runat="server" RepeatColumns="3" >
</asp:CheckBoxList>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" />
</Columns>
<FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
<HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
<PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
<RowStyle BackColor="White" ForeColor="#003399" />
<SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
<SortedAscendingCellStyle BackColor="#EDF6F6" />
<SortedAscendingHeaderStyle BackColor="#0D4AC4" />
<SortedDescendingCellStyle BackColor="#D6DFDF" />
<SortedDescendingHeaderStyle BackColor="#002876" />
</asp:GridView>
<pre lang="HTML">
in pageload the data of gridview retrevied from datasource but the data of checklist column retrevied from diffrent dataset :
GridView1.DataSource = bal_obj.get_lisense_data(scholl_id)
GridView1.DataBind()
i made event rowdatabound to bindchecklist in itemtemplate and in edittemplate
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If (e.Row.RowState And DataControlRowState.Alternate) > 0 Then
Dim chkBrand As CheckBoxList = DirectCast(e.Row.FindControl("chlist_item"), CheckBoxList)
chkBrand.DataSource = bal_obj.get_school_stages(scholl_id)
chkBrand.DataTextField = "stage_name"
chkBrand.DataValueField = "stage_id"
chkBrand.DataBind()
End If
If (e.Row.RowState And DataControlRowState.Edit) > 0 Then
Dim chkBrand As CheckBoxList = DirectCast(e.Row.FindControl("chlist_edit"), CheckBoxList)
chkBrand.DataSource = bal_obj.get_allstage()
chkBrand.DataTextField = "stage_name"
chkBrand.DataValueField = "stage_id"
chkBrand.DataBind()
End If
End If
End Sub