Saroj13
asked on
How Gridview having no rows display header and one empty row using c# and asp.net
Hi,
I have gridview having two columns script title and script text.
1. If datareader is having no rows, how to display gridview header with one empty row in asp.net and c#?
2. If gridview is having no rows, display detailsview header also with one empty row.
3. If gridview script title linkbutton is selected, how to change the forecolor of selected title?
I have gridview having two columns script title and script text.
1. If datareader is having no rows, how to display gridview header with one empty row in asp.net and c#?
2. If gridview is having no rows, display detailsview header also with one empty row.
3. If gridview script title linkbutton is selected, how to change the forecolor of selected title?
<table style="width:210%;" >
<tr style="vertical-align:top;">
<td style="border:0px solid #000; width:200px;">
<asp:GridView ID="ScriptsGridView" runat="server" CellPadding="1" CellSpacing="1"
HeaderStyle-CssClass="nodrag nodrop" AutoGenerateColumns="False"
HeaderStyle-ForeColor="White" HeaderStyle-BackColor="#F28B13"
style="position: relative; top: -52px; left: 322px;"
Height="100%" Width="102%" DataKeyNames="ScriptID"
BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1pt"
onrowcommand="ScriptsGridView_RowCommand">
<HeaderStyle CssClass="nodrag nodrop" BackColor="#43816E" BorderColor="White" BorderStyle="Solid" BorderWidth="1px" Font-Bold="true" ForeColor="White"></HeaderStyle>
<RowStyle Height="20px" />
<Columns>
<asp:TemplateField HeaderText="Script Name">
<ItemTemplate>
<asp:linkbutton ID="TitleLinkButton" runat="server" Text='<%# Eval("Title") %>' CommandName="Select" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>
<td id ="details" style="position: relative; top: -52px; left: 322px; width:60%; border-bottom-style:solid 1pt; border-right-style:solid 1pt; border-color:#cccccc; " runat="server" >
<asp:DetailsView ID="DetailsView1" runat="server" Height="100%" Width="100%" BorderStyle="None" BorderColor="#ffffff" FieldHeaderStyle-BorderStyle="None"
AutoGenerateRows="False" DataSourceID="SomeOtherSqlDataSource" HeaderText="ScriptText"
HeaderStyle-CssClass="nodrag nodrop">
<HeaderStyle Height="33px" HorizontalAlign="Center" BackColor="#43816E" BorderColor="#cccccc" BorderStyle="Solid" BorderWidth="1px" Font-Bold="true" ForeColor="White"></HeaderStyle>
<RowStyle Height="20px" />
<Fields>
<asp:TemplateField ItemStyle-BorderStyle="None" HeaderStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="DetailLabel" runat="server" Text='<%# Eval("ScriptTextPlain") %>' BorderStyle="None" />
</ItemTemplate>
<HeaderStyle Font-Bold="True" />
</asp:TemplateField>
</Fields>
</asp:DetailsView>
</td>
</tr>
</table>
<asp:SqlDataSource
ID="SomeOtherSqlDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:ScriptsConnectionString %>"
SelectCommand="usp_GetScriptTextDetail_ScriptOrder"
SelectCommandType="StoredProcedure"
>
<SelectParameters>
<asp:ControlParameter ControlID="ScriptsGridView" PropertyName="SelectedValue" Name="Script_ID" Type="Int32" DefaultValue="1" />
</SelectParameters>
</asp:SqlDataSource>
c#
SqlDataReader rdr = GetScriptsDataReader();
if (!rdr.HasRows)
{
ScriptsGridView.DataSource = rdr;
ScriptsGridView.DataBind();
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i dont want to change the row color. i want to change the color of linbutton text on linkbutton click.
plz send code,
plz send code,
I've requested that this question be deleted for the following reason:
The question has either no comments or not enough useful information to be called an "answer".
The question has either no comments or not enough useful information to be called an "answer".
I did answer at least on of his questions (1 and 2) .... I don't kwow the answer for the other ones
3) Accept one or more Expert posts as the answer: ID: 38344367
http://www.daniweb.com/web-development/aspnet/threads/202708/change-the-color-of-gridview-row-when-the-row-is-selected
Change gridview row color at linkbutton click which is a templated field in gridview RSS
http://forums.asp.net/t/1730233.aspx/1