Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
With a datatable that has a column as hyperlink, is it possible to select the whole row?
If so, how can we select and highlight so user can see the row is selected?
if you are talking about gridview try see about GridView.SelectedRowStyle Property
you can try it like this
<asp:gridview id="CustomersGridView"
...
autogenerateselectbutton="True"
selectedindex="1"
... >
<Columns>
...
</Columns>
<selectedrowstyle backcolor="LightCyan"
forecolor="DarkBlue"
font-bold="true"/>
</asp:gridview>
or if you have special css class for selected row
<asp:gridview id="CustomersGridView"
...
autogenerateselectbutton="True"
selectedindex="1"
... >
<Columns>
...
</Columns>
<selectedrowstyle CssClass="YouCssClassForSelectedRow"/>
</asp:gridview>
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I need to change the class of a div nested inside a gridview item template, i have given the runat="server" tag and an id for the div. How can we change the class of that particular div upon gridview databind based on each row conditions.
ASPX
<asp:GridView ID="gv" runat="server" OnRowDataBound="gv_OnRowDataBound">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<div id="yourDiv" runat="server"></div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Code-behind
protected void gv_RowDataBound(object sender, GridViewRowEventArgs e) {
if (e.Row.RowType == DataControlRowType.DataRow) {
HtmlGenericControl div = (HtmlGenericControl)e.Row.FindControl("yourDiv");
div.Attributes.Add("class", "ClassYouWantToAdd");
}
}
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Can someone give an idea how I can see details of a selected product (suppose) regarding The productID in another page with HyperLink?? I have Tried To pass The ID with QueryString with Linq. But not done.
Mark up
<asp:HyperLink ID ="hyperLink" runat="server" />
C#
Set the url:
hyperLink.NavigateUrl = "somePage.aspx?id=123";
Read the url query string in somePage.aspx
var id = Request.QueryString["id"];
You have multiple problems in your code (as given in your comment section).
Here is what you have
<asp:HyperLink ID = "View" server = "runat" NavigateUrl = '<%# ("~/pageredirect.aspx") + eval("CatergoryID") %>'>View</asp:HyperLink>
Issues:
you have server = "runat" and it should be runat="server"
you are concatenating CatergoryID with the redirect page and not really passing as querystring which will really append the value like pageredirect.aspx + categoryid
you are binding as CatergoryID and retrieving by query string name CategoryID which is not same (notice the typo)
Change your asp:HyperLink definition in the itemtemplate of the gridview in Approve.aspx as below
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID="hlView" runat="server" NavigateUrl='<%# Eval("CategoryID", "~/pageredirect.aspx?CategoryID={0}") %>' Text="View" />
</ItemTemplate>
</asp:TemplateField>
and then in your pageredirect.aspx.cs access the querystring value as
if (!String.IsNullOrEmpty(Request.QueryString["CategoryID"]))
{
int m = Int32.Parse(Request.QueryString["CategoryID"]);
....
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
i need that by default Gridview must have 10 empty rows with only one Column that column should have Textbox
here is my script of gridview
<asp:GridView ID="gv_Others" runat="server" AutoGenerateColumns="false"
onrowdatabound="gv_Others_RowDataBound"
onrowcreated="gv_Others_RowCreated">
<Columns>
<asp:TemplateField ItemStyle-Width="40px">
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<ItemTemplate>
<asp:TextBox ID="txtemp" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
is that possible to create 10 empty rows by default in a gridview?
you can try this
string[] str = new string[10];
List lstStr = str.ToList<string>();
gv_Others.DataSource = lstStr ;
gv_Others.DataBind();
var list = new List<string>();
for (int i = 0; i < 10; i++)
{
list.Add(string.Empty);
}
gv_Others.DataSource = list;
gv_Others.DataBind();
This is the quickest and dirtiest way I could think of, would I write something like this? No. But then I'm sure you have your reasons, would have been better if you'd written in your question what you were trying to achieve then we could have helped more and your question wouldn't have got marked down.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Mine checkboxlist is very ugly. the Box doesn't align properly. See the screenshot.
I would like to mention that your checkbox list will be stick to the Width="195px".
So suggestion from my side is either increase the width as per your design or remove it as mentioned below :
<asp:CheckBoxList runat="server" ID="cblType"
OnSelectedIndexChanged="cblType_OnSelectedIndexChanged" AutoPostBack="True"
RepeatDirection="Horizontal">
<Items>
<asp:ListItem Text="IPP Stories" Value="IPP Stories"></asp:ListItem>
<asp:ListItem Text="OutReach Activities " Value="OutReach Activities"></asp:ListItem>
<asp:ListItem Text="CCA" Value="CCA"></asp:ListItem>
<asp:ListItem Text="Community Work" Value="Community Work"></asp:ListItem>
<asp:ListItem Text="Competition" Value="Competition"></asp:ListItem>
<asp:ListItem Text="Overseas Experience" Value="Overseas Experience"></asp:ListItem>
<asp:ListItem Text="FYPJ" Value="FYPJ"></asp:ListItem>
</Items>
</asp:CheckBoxList>
Suggestion :
If I am facing this situation then I would make it in two rows by adding RepeatColumns="3" or RepeatColumns="4" in CheckboxList property.
I don't think you need to specify any width here, try not to and perhaps it will do the job. If not, please post the pertinent css style (if any)...
<asp:CheckBoxList runat="server" ID="cblType"
OnSelectedIndexChanged="cblType_OnSelectedIndexChanged" AutoPostBack="True"
RepeatDirection="Horizontal">
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I have created a user profile page for a simple website in C#.net. I'm using detailsview to show the user information but I want to hide the column names stored in database instead of it I want to write them in html table. Details view provide two columns First one for the Column names in the database and the second for value for these columns. I want to remove the first one and define it manually.
Is there any way to hide the all column names and show only values of detailsview, and if not then please suggest me to retrieve information for profile page and editing feature also?
Code for detailsview:
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
BorderWidth="0px" DataSourceID="UserDetails" Height="287px"
style="text-align: left" Width="394px">
<Fields>
<asp:BoundField DataField="Login" HeaderText="Login" SortExpression="Login" />
<asp:BoundField DataField="Uname" HeaderText="Uname" SortExpression="Uname" />
<asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
<asp:BoundField DataField="DOB" HeaderText="DOB" SortExpression="DOB" />
<asp:BoundField DataField="Hometown" HeaderText="Hometown"
SortExpression="Hometown" />
<asp:BoundField DataField="Interests" HeaderText="Interests"
SortExpression="Interests" />
</Fields>
</asp:DetailsView>
Code for database:
<asp:SqlDataSource ID="UserDetails" runat="server"
ConnectionString="<%$ ConnectionStrings:ConString %>"
SelectCommand="SELECT [Login], [Uname], [Email], [DOB], [Hometown], [Interests] FROM [Profile] WHERE ([Login] LIKE '%' + #Login + '%')">
<SelectParameters>
<asp:SessionParameter Name="Login" SessionField="usr" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
You can hide or rename the column of detailview without using html table , fellow this link
http://www.devmanuals.com/tutorials/ms/aspdotnet/detailsview.html