hello,
i am facing some problem to retrieve some records..
i am using a table in which records are as like below.
hotelid hotel name facility amenity room
---------------------------------------------
1 abc 1,2 2,3 3,4
2 bcs 4,5 6,7 4
when we click on highlighted hyperlink, then following table will be open-
roomid room amenity
-------------------------
3 abc 1,2
2 bcs 4,5
again, when we click on highlighted hyperlink, then following table will be open-
amenityid room amenity cost
---------------------------------------------
1 abc ghh 567
2 bcs ythd 5676
my problem is that my facility & amenity columns hyperlinks are working properly..but everytime when i click on room hyperlink record.. it gives some error in gridview_rowdata bound on room page while it should have to firdtly go to page load but it goes directly to roompage's rowdata bound event.. i dont know why it is happening..?
please help me..
i am sending you my coding files as well..
please can resolve my problem..
i' ve to submit this today.
please reply me..
thank you.
Loading


Rahul Bhatt165 reputationPosted Jul 26, 2012, 3:32 AM EDT
To achieve this task,
You need to added BoundColumn in Gridvew
Set AutoGenerated = "false"
Make your GridView as following way
<asp:GridView ID="GridView2" runat="server" AllowPaging="True" CellPadding="4" EmptyDataText="No Records Found"
ForeColor="#333333" GridLines="None" Width="408px" OnRowCancelingEdit="GridView2_RowCancelingEdit1"
OnRowEditing="GridView2_RowEditing" OnRowUpdating="GridView2_RowUpdating" OnPageIndexChanged="GridView2_PageIndexChanged"
OnRowDataBound="GridView2_RowDataBound" AutoGenerateColumns="false">
<RowStyle BackColor="#EFF3FB" />
<Columns>
<asp:BoundField HeaderText="Id" DataField="Id" />
<asp:BoundField HeaderText="RoomType" DataField="RoomType" />
<asp:BoundField HeaderText="no_rooms" DataField="no_rooms" />
<asp:BoundField HeaderText="cost" DataField="cost" />
<asp:BoundField HeaderText="Aminities" DataField="Aminities" />
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
ItemTemplate>
asp:TemplateField>
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:CheckBox ID="CheckBox3" runat="server" />
ItemTemplate>
asp:TemplateField>
<asp:CommandField ShowEditButton="True" />
Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
asp:GridView>
Make your RowDatabound event as following way
protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string hotelname = TextBox4.Text;
string roomtype = e.Row.Cells[1].Text;
string AminID = e.Row.Cells[4].Text;
string Aminitiesval = " ";
Aminitiesval = Aminitiesval + "" + AminID + "" + ",";
e.Row.Cells[4].Text = Aminitiesval;
}
}
Priyank Khare154 reputationPosted Jul 26, 2012, 3:58 AM EDT
it is working quit well.
thanks alot.
i just ask 1 more ques:-
in my master table there are 20 columns. if i am using a single grid, then there is a problem of horizontal scrolling.
so, i want to split my gridview into 2 parts such that:-
1. it will display only in 1 page.
2. if we edit/delete/insert any row/record from the grid then it will do that in whole rows incluing both grids..
for example:-
both grid have 8 columns & if perform delete for any row, it should be deleted from the both grid because both are of one table.
please give me its solution as well.
thank you.