Click here to Skip to main content
15,883,705 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Creating Excel file from dataset data Pin
Dhruvil30-Jun-06 5:34
Dhruvil30-Jun-06 5:34 
GeneralRe: Creating Excel file from dataset data Pin
ketankumar1-Jul-06 23:39
ketankumar1-Jul-06 23:39 
Questionproblem with inheriring a page Pin
sishya29-Jun-06 15:31
sishya29-Jun-06 15:31 
AnswerRe: problem with inheriring a page Pin
minhpc_bk29-Jun-06 17:06
minhpc_bk29-Jun-06 17:06 
AnswerRe: problem with inheriring a page Pin
Guffa29-Jun-06 19:02
Guffa29-Jun-06 19:02 
GeneralBut the placeholder control is declared in the code behind class also . Pin
sishya29-Jun-06 19:15
sishya29-Jun-06 19:15 
AnswerRe: But the placeholder control is declared in the code behind class also . Pin
Guffa29-Jun-06 19:40
Guffa29-Jun-06 19:40 
QuestionManage a GridView's HyperLinkField column's width? [modified] Pin
-Dr_X-29-Jun-06 10:24
-Dr_X-29-Jun-06 10:24 
Scenario: I was using Template columns with ImageButtons with no problem controlling the columns' width. However template columns are not allowed when 'EnableSortingAndPagingCallbacks="True"'.
Original html code:
<asp:TemplateField ItemStyle-Width="22px">
  <ItemTemplate>
    <asp:ImageButton ID="imbView" runat="server" ImageUrl="~/Images/ViewSearch.gif"  />
  </ItemTemplate>
</asp:TemplateField>         
<asp:TemplateField ItemStyle-Width="22px">
  <ItemTemplate>
    <asp:ImageButton ID="imgEdit" runat="server" ImageUrl="~/Images/Edit.gif"  />
  </ItemTemplate>
</asp:TemplateField> 
<asp:TemplateField ItemStyle-Width="22px">
  <ItemTemplate>
    <asp:ImageButton ID="imgDelete" runat="server" ImageUrl="~/Images/Delete.gif"  />
  </ItemTemplate>
</asp:TemplateField>                       
<asp:TemplateField ItemStyle-Width="22px">
  <ItemTemplate>
    <asp:ImageButton ID="imgPrint" runat="server" ImageUrl="~/Images/Print.gif"  />
  </ItemTemplate>
</asp:TemplateField>
So I replaced the template columns with HyperLinkField. Then in the onRowDataBound event in the code-behind, I set the images to the respective links.
</asp:HyperLinkField DataNavigateUrlFormatString="~/Invoices/Invoice.aspx?id={0}&Readonly" DataNavigateUrlFields="InvoiceID" ItemStyle-Width="20px" />
</asp:HyperLinkField DataNavigateUrlFormatString="~/Invoices/Invoice.aspx?id={0}&Edit" DataNavigateUrlFields="InvoiceID" />
</asp:HyperLinkField DataNavigateUrlFormatString="~/Reports/Reports.aspx?DeleteFromSomeWhere" DataNavigateUrlFields="InvoiceID" />
</asp:HyperLinkField DataNavigateUrlFormatString="~/Reports/Reports.aspx?id={0}" DataNavigateUrlFields="InvoiceID" />
public void dgData_onRowDataBound(Object src, GridViewRowEventArgs e)
{
  if (e.Row.RowType == DataControlRowType.DataRow)
  {
    DataRowView row = (DataRowView)e.Row.DataItem;
    HyperLink link = (HyperLink)e.Row.Cells[0].Controls[0];
    if (!(link == null))
    {
      link.ImageUrl = "~/Images/ViewSearch.gif";
      link.ToolTip = "Print";
    }
    link = (HyperLink)e.Row.Cells[1].Controls[0];
    if (!(link == null))
    {
      link.ImageUrl = "~/Images/Edit.gif";
      link.ToolTip = "Print";
    }
    link = (HyperLink)e.Row.Cells[2].Controls[0];
    if (!(link == null))
    {
      link.ImageUrl = "~/Images/Delete.gif";
      link.ToolTip = "Delete Invoice";
      link.Attributes.Add("onclick", "javascript: alert('works'); return false;");
    }
    link = (HyperLink)e.Row.Cells[3].Controls[0];
    if (!(link == null))
    {
      link.ImageUrl = "~/Images/Print.gif";
      link.ToolTip = "Print Invoice";
    }
  }
}
After the changes, which fixes the EnableSortingAndPagingCallbacks problems, the column images (ViewSearch, Edit, Delete & Print) are spaced apart instead of nicely next to each other. I have tried the following variations with no luck.
        if (!(link==null))
        {
          link.ImageUrl = "~/Images/ViewSearch.gif";
          link.ToolTip="Print";
          link.Width = System.Web.UI.WebControls.Unit.Pixel(20);
          e.Row.Cells[0].Style.Add("max-width", "20px");
          e.Row.Cells[0].Style.Add(System.Web.UI.HtmlTextWriterStyle.Width, "20px");
          e.Row.Cells[0].Width = System.Web.UI.WebControls.Unit.Pixel(20);
        }
and also
  <asp:HyperLinkField ... ItemStyle-Width="20px" ControlStyle-Width="20px"/>

Thanks in advance,
Michael

I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious.
Vince Lombardi (1913-1970)

-- modified at 17:18 Thursday 29th June, 2006
AnswerRe: Manage a GridView's HyperLinkField column's width? Pin
minhpc_bk29-Jun-06 17:02
minhpc_bk29-Jun-06 17:02 
GeneralRe: Manage a GridView's HyperLinkField column's width? Pin
-Dr_X-5-Jul-06 7:09
-Dr_X-5-Jul-06 7:09 
QuestionSession [modified] Pin
kirthikirthi29-Jun-06 9:04
kirthikirthi29-Jun-06 9:04 
AnswerRe: Session Pin
Guffa29-Jun-06 11:44
Guffa29-Jun-06 11:44 
AnswerRe: Session Pin
minhpc_bk29-Jun-06 17:08
minhpc_bk29-Jun-06 17:08 
Questionhow to work with multiple web forms Pin
ravindradonkada29-Jun-06 8:32
ravindradonkada29-Jun-06 8:32 
AnswerRe: how to work with multiple web forms [modified] Pin
eggsovereasy29-Jun-06 9:40
eggsovereasy29-Jun-06 9:40 
AnswerRe: how to work with multiple web forms Pin
wEb GuRu...30-Jun-06 7:14
wEb GuRu...30-Jun-06 7:14 
QuestionFormsAuthentication Problem in ASP.NET 2.0 Pin
seee sharp29-Jun-06 7:38
seee sharp29-Jun-06 7:38 
AnswerRe: FormsAuthentication Problem in ASP.NET 2.0 Pin
eggsovereasy29-Jun-06 9:34
eggsovereasy29-Jun-06 9:34 
AnswerRe: FormsAuthentication Problem in ASP.NET 2.0 Pin
minhpc_bk29-Jun-06 17:11
minhpc_bk29-Jun-06 17:11 
QuestionCheck Whether GridView Contain any row Pin
Muhammad Chitrali29-Jun-06 7:08
Muhammad Chitrali29-Jun-06 7:08 
AnswerRe: Check Whether GridView Contain any row Pin
eggsovereasy29-Jun-06 9:32
eggsovereasy29-Jun-06 9:32 
AnswerRe: Check Whether GridView Contain any row [modified] Pin
minhpc_bk29-Jun-06 17:14
minhpc_bk29-Jun-06 17:14 
QuestionContent Page with functions in Code behind Pin
Andy1227929-Jun-06 6:51
Andy1227929-Jun-06 6:51 
AnswerRe: Content Page with functions in Code behind Pin
minhpc_bk29-Jun-06 17:22
minhpc_bk29-Jun-06 17:22 
QuestionASP.net Shoping Cart Pin
wEb GuRu...29-Jun-06 5:46
wEb GuRu...29-Jun-06 5:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.